vendor/croisiland/common-bundle/src/Entity/Offer/OfferCategory.php line 27

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Offer;
  4. use Crea\MediaBundle\Entity\MediaTagOwnerInterface;
  5. use Crea\ToolsBundle\Entity\CreaIconIdentifiedInterface;
  6. use Crea\ToolsBundle\Entity\CreaIconTrait;
  7. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  8. use Croisiland\CommonBundle\Annotation\Offer\OfferCategoryFormValidator;
  9. use Croisiland\CommonBundle\Entity\Traits\ColorTrait;
  10. use Croisiland\CommonBundle\Entity\Traits\IsActiveTrait;
  11. use Croisiland\CommonBundle\Entity\Traits\ListOrderTrait;
  12. use Croisiland\CommonBundle\Repository\Offer\OfferCategoryRepository;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Doctrine\Common\Util\ClassUtils;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Gedmo\Mapping\Annotation as Gedmo;
  18. /**
  19. * @ORM\Entity(repositoryClass=OfferCategoryRepository::class)
  20. *
  21. * @OfferCategoryFormValidator(groups={"offer_category_form_validator"})
  22. */
  23. class OfferCategory implements CreaIconIdentifiedInterface, MediaTagOwnerInterface
  24. {
  25. use CreaIconTrait;
  26. use ColorTrait;
  27. use ListOrderTrait;
  28. use IsActiveTrait;
  29. use LifecycleUserIdentifierTrait;
  30. /**
  31. * @ORM\Id
  32. *
  33. * @ORM\GeneratedValue
  34. *
  35. * @ORM\Column(type="integer")
  36. */
  37. private ?int $id;
  38. /**
  39. * @ORM\Column(type="string", length=255)
  40. */
  41. private ?string $name = null;
  42. /**
  43. * @ORM\Column(type="string", length=100, unique=true)
  44. *
  45. * @Gedmo\Slug(fields={"name"}, updatable=false, unique=true)
  46. */
  47. private ?string $slug = null;
  48. /**
  49. * @ORM\Column(type="text", nullable=true)
  50. */
  51. private ?string $description = null;
  52. /**
  53. * @var Collection<int, Offer>
  54. *
  55. * @ORM\OneToMany(targetEntity=Offer::class, mappedBy="offerCategory")
  56. */
  57. private Collection $offers;
  58. public function __construct()
  59. {
  60. $this->offers = new ArrayCollection();
  61. }
  62. public function getId(): ?int
  63. {
  64. return $this->id;
  65. }
  66. public function getName(): ?string
  67. {
  68. return $this->name;
  69. }
  70. public function setName(?string $name): self
  71. {
  72. $this->name = $name;
  73. return $this;
  74. }
  75. public function getSlug(): ?string
  76. {
  77. return $this->slug;
  78. }
  79. public function setSlug(?string $slug): self
  80. {
  81. $this->slug = $slug;
  82. return $this;
  83. }
  84. public function getDescription(): ?string
  85. {
  86. return $this->description;
  87. }
  88. public function setDescription(?string $description): self
  89. {
  90. $this->description = $description;
  91. return $this;
  92. }
  93. /**
  94. * @return Collection<int, Offer>
  95. */
  96. public function getOffers(): Collection
  97. {
  98. return $this->offers;
  99. }
  100. public function addOffer(Offer $offer): self
  101. {
  102. if (!$this->offers->contains($offer)) {
  103. $this->offers[] = $offer;
  104. $offer->setOfferCategory($this);
  105. }
  106. return $this;
  107. }
  108. public function removeOffer(Offer $offer): self
  109. {
  110. if ($this->offers->removeElement($offer)) {
  111. // set the owning side to null (unless already changed)
  112. if ($offer->getOfferCategory() === $this) {
  113. $offer->setOfferCategory(null);
  114. }
  115. }
  116. return $this;
  117. }
  118. public function getIconLabel(): ?string
  119. {
  120. return $this->getName();
  121. }
  122. /**
  123. * Method liée au Média Bundle
  124. */
  125. public function getMediaTagOwnerLabel(): ?string
  126. {
  127. return $this->getName();
  128. }
  129. /**
  130. * Method liée au Média Bundle
  131. * @return class-string
  132. */
  133. public function getFqcn(): string
  134. {
  135. return ClassUtils::getClass($this);
  136. }
  137. }