vendor/crea/media-bundle/src/Entity/MediaFamily.php line 19

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Crea\MediaBundle\Entity;
  4. use Crea\MediaBundle\Entity\Enum\MediaFamilyCodeEnum;
  5. use Crea\MediaBundle\Repository\MediaFamilyRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Stringable;
  10. /**
  11. * @ORM\Entity(repositoryClass=MediaFamilyRepository::class)
  12. *
  13. * @ORM\Table(name="media_family")
  14. */
  15. class MediaFamily implements Stringable, FileConstraintInterface, CodeIdentifiedInterface
  16. {
  17. /**
  18. * @ORM\Id
  19. *
  20. * @ORM\GeneratedValue
  21. *
  22. * @ORM\Column(type="integer")
  23. */
  24. private ?int $id = null;
  25. /**
  26. * @ORM\Column(type="string", length=255)
  27. */
  28. private ?string $label = null;
  29. /**
  30. * @ORM\Column(type="string", enumType=MediaFamilyCodeEnum::class, nullable=true, unique=true)
  31. */
  32. private ?MediaFamilyCodeEnum $code = null;
  33. /**
  34. * Unit : Octet.
  35. *
  36. * @ORM\Column(type="integer", nullable=true)
  37. */
  38. private ?int $maxSize = null;
  39. /**
  40. * Unit : pixel.
  41. *
  42. * @ORM\Column(type="integer", nullable=true)
  43. */
  44. private ?int $maxDimention = null;
  45. /**
  46. * @var Collection<int, MediaType>
  47. *
  48. * @ORM\OneToMany(targetEntity=MediaType::class, mappedBy="mediaFamily")
  49. */
  50. private Collection $mediaTypes;
  51. public function __construct()
  52. {
  53. $this->mediaTypes = new ArrayCollection();
  54. }
  55. public function __toString(): string
  56. {
  57. return $this->label ?: 'MediaFamily - ('.$this->id.')';
  58. }
  59. public function getId(): ?int
  60. {
  61. return $this->id;
  62. }
  63. public function setId(?int $id): MediaFamily
  64. {
  65. $this->id = $id;
  66. return $this;
  67. }
  68. public function getLabel(): ?string
  69. {
  70. return $this->label;
  71. }
  72. public function setLabel(?string $label): MediaFamily
  73. {
  74. $this->label = $label;
  75. return $this;
  76. }
  77. public function getCode(): ?MediaFamilyCodeEnum
  78. {
  79. return $this->code;
  80. }
  81. public function setCode(?MediaFamilyCodeEnum $code): MediaFamily
  82. {
  83. $this->code = $code;
  84. return $this;
  85. }
  86. public function getMaxSize(): ?int
  87. {
  88. return $this->maxSize;
  89. }
  90. public function setMaxSize(?int $maxSize): MediaFamily
  91. {
  92. $this->maxSize = $maxSize;
  93. return $this;
  94. }
  95. public function getMaxDimention(): ?int
  96. {
  97. return $this->maxDimention;
  98. }
  99. public function setMaxDimention(?int $maxDimention): MediaFamily
  100. {
  101. $this->maxDimention = $maxDimention;
  102. return $this;
  103. }
  104. /**
  105. * @return Collection<int, MediaType>
  106. */
  107. public function getMediaTypes(): Collection
  108. {
  109. return $this->mediaTypes;
  110. }
  111. public function addMediaType(MediaType $mediaType): self
  112. {
  113. if (!$this->mediaTypes->contains($mediaType)) {
  114. $this->mediaTypes[] = $mediaType;
  115. $mediaType->setMediaFamily($this);
  116. }
  117. return $this;
  118. }
  119. public function removeMediaType(MediaType $mediaType): self
  120. {
  121. if ($this->mediaTypes->removeElement($mediaType)) {
  122. if ($mediaType->getMediaFamily() === $this) {
  123. $mediaType->setMediaFamily(null);
  124. }
  125. }
  126. return $this;
  127. }
  128. }