vendor/croisiland/common-bundle/src/Entity/Cabin/CabinCategoryHighlight.php line 23

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Cabin;
  4. use Crea\ToolsBundle\Entity\CreaIconIdentifiedInterface;
  5. use Crea\ToolsBundle\Entity\CreaIconTrait;
  6. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  7. use Crea\ToolsBundle\Traits\KeyValueTrait;
  8. use Croisiland\CommonBundle\Entity\Traits\IsActiveTrait;
  9. use Croisiland\CommonBundle\Entity\Traits\ListOrderTrait;
  10. use Croisiland\CommonBundle\Repository\Cabin\CabinCategoryHighlightRepository;
  11. use Croisiland\CommonBundle\Annotation\Cabin\CabinCategoryHighlightFormValidator;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. /**
  16. * @ORM\Entity(repositoryClass=CabinCategoryHighlightRepository::class)
  17. * @CabinCategoryHighlightFormValidator(groups={"cabin_category_highlight_form_validator"})
  18. */
  19. class CabinCategoryHighlight implements CreaIconIdentifiedInterface
  20. {
  21. use IsActiveTrait;
  22. use ListOrderTrait;
  23. use LifecycleUserIdentifierTrait;
  24. use CreaIconTrait;
  25. use KeyValueTrait;
  26. /**
  27. * @ORM\Id
  28. * @ORM\GeneratedValue
  29. * @ORM\Column(type="integer")
  30. */
  31. private ?int $id = null;
  32. /**
  33. * @ORM\Column(type="string", length=255, nullable=false)
  34. */
  35. private ?string $name = null;
  36. /**
  37. * @ORM\Column(type="text", nullable=true)
  38. */
  39. private ?string $description = null;
  40. /**
  41. * @var Collection<int, CabinCategory>
  42. * @ORM\ManyToMany(targetEntity=CabinCategory::class, inversedBy="highlights")
  43. */
  44. private Collection $cabinCategories;
  45. public function __construct()
  46. {
  47. $this->cabinCategories = new ArrayCollection();
  48. }
  49. public function getId(): ?int
  50. {
  51. return $this->id;
  52. }
  53. public function getName(): ?string
  54. {
  55. return $this->name;
  56. }
  57. public function setName(string $name): self
  58. {
  59. $this->name = $name;
  60. return $this;
  61. }
  62. public function getDescription(): ?string
  63. {
  64. return $this->description;
  65. }
  66. public function setDescription(?string $description): self
  67. {
  68. $this->description = $description;
  69. return $this;
  70. }
  71. /**
  72. * @return Collection<int, CabinCategory>
  73. */
  74. public function getCabinCategories(): Collection
  75. {
  76. return $this->cabinCategories;
  77. }
  78. public function addCabinCategory(CabinCategory $cabinCategory): self
  79. {
  80. if (!$this->cabinCategories->contains($cabinCategory)) {
  81. $this->cabinCategories[] = $cabinCategory;
  82. $cabinCategory->addHighlight($this);
  83. }
  84. return $this;
  85. }
  86. public function removeCabinCategory(CabinCategory $cabinCategory): self
  87. {
  88. if ($this->cabinCategories->removeElement($cabinCategory)) {
  89. $cabinCategory->removeHighlight($this);
  90. }
  91. return $this;
  92. }
  93. public function getIconLabel(): ?string
  94. {
  95. return $this->getName() ?? null;
  96. }
  97. }