vendor/croisiland/common-bundle/src/Entity/Cabin/CabinSubType.php line 26

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Cabin;
  4. use Crea\MediaBundle\Entity\MediaTagOwnerInterface;
  5. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  6. use Crea\ToolsBundle\Traits\KeyValueTrait;
  7. use Croisiland\CommonBundle\Annotation\Cabin\CabinSubTypeFormValidator;
  8. use Croisiland\CommonBundle\Entity\Company\Company;
  9. use Croisiland\CommonBundle\Entity\Traits\IsActiveTrait;
  10. use Croisiland\CommonBundle\Entity\Traits\ListOrderTrait;
  11. use Croisiland\CommonBundle\Repository\Cabin\CabinSubTypeRepository;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\Common\Util\ClassUtils;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Gedmo\Mapping\Annotation as Gedmo;
  17. /**
  18. * @ORM\Entity(repositoryClass=CabinSubTypeRepository::class)
  19. *
  20. * @CabinSubTypeFormValidator(groups={"cabin_sub_type_form_validator"})
  21. */
  22. class CabinSubType implements MediaTagOwnerInterface
  23. {
  24. use IsActiveTrait;
  25. use ListOrderTrait;
  26. use LifecycleUserIdentifierTrait;
  27. use KeyValueTrait;
  28. /**
  29. * @ORM\Id
  30. *
  31. * @ORM\GeneratedValue
  32. *
  33. * @ORM\Column(type="integer")
  34. */
  35. private ?int $id = null;
  36. /**
  37. * @ORM\Column(type="string", length=255)
  38. */
  39. private ?string $name = null;
  40. /**
  41. * @ORM\Column(type="string", length=255, nullable=true)
  42. */
  43. private ?string $shortName = null;
  44. /**
  45. * @ORM\Column(type="string", length=100, unique=true)
  46. *
  47. * @Gedmo\Slug(fields={"name"}, updatable=false, unique=true)
  48. */
  49. private ?string $slug = null;
  50. /**
  51. * @ORM\Column(type="text", nullable=true)
  52. */
  53. private ?string $description = null;
  54. /**
  55. * @ORM\Column(type="string", length=255, nullable=true)
  56. */
  57. private ?string $cabinAreaMin = null;
  58. /**
  59. * @ORM\Column(type="string", length=255, nullable=true)
  60. */
  61. private ?string $cabinAreaMax = null;
  62. /**
  63. * @ORM\Column(type="string", length=255, nullable=true)
  64. */
  65. private ?string $balconyAreaMin = null;
  66. /**
  67. * @ORM\Column(type="string", length=255, nullable=true)
  68. */
  69. private ?string $balconyAreaMax = null;
  70. /**
  71. * @ORM\ManyToOne(targetEntity=CabinType::class, inversedBy="cabinSubTypes")
  72. * @ORM\JoinColumn(nullable=false)
  73. */
  74. private ?CabinType $cabinType = null;
  75. /**
  76. * @var Collection<int, CabinCategory>
  77. *
  78. * @ORM\OneToMany(targetEntity=CabinCategory::class, mappedBy="cabinSubType", orphanRemoval=true)
  79. * @ORM\OrderBy({"listOrder" = "ASC"})
  80. */
  81. private Collection $cabinCategories;
  82. /**
  83. * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="cabinSubTypes")
  84. *
  85. * @ORM\JoinColumn(nullable=false)
  86. */
  87. private ?Company $company = null;
  88. public function __construct()
  89. {
  90. $this->cabinCategories = new ArrayCollection();
  91. }
  92. public function getId(): ?int
  93. {
  94. return $this->id;
  95. }
  96. public function getName(): ?string
  97. {
  98. return $this->name;
  99. }
  100. public function setName(?string $name): self
  101. {
  102. $this->name = $name;
  103. return $this;
  104. }
  105. public function getShortName(): ?string
  106. {
  107. return $this->shortName;
  108. }
  109. public function setShortName(?string $shortName): self
  110. {
  111. $this->shortName = $shortName;
  112. return $this;
  113. }
  114. public function getSlug(): ?string
  115. {
  116. return $this->slug;
  117. }
  118. public function setSlug(?string $slug): self
  119. {
  120. $this->slug = $slug;
  121. return $this;
  122. }
  123. public function getDescription(): ?string
  124. {
  125. return $this->description;
  126. }
  127. public function setDescription(?string $description): self
  128. {
  129. $this->description = $description;
  130. return $this;
  131. }
  132. public function getCabinAreaMin(): ?string
  133. {
  134. return $this->cabinAreaMin;
  135. }
  136. public function setCabinAreaMin(?string $cabinAreaMin): self
  137. {
  138. $this->cabinAreaMin = $cabinAreaMin;
  139. return $this;
  140. }
  141. public function getCabinAreaMax(): ?string
  142. {
  143. return $this->cabinAreaMax;
  144. }
  145. public function setCabinAreaMax(?string $cabinAreaMax): self
  146. {
  147. $this->cabinAreaMax = $cabinAreaMax;
  148. return $this;
  149. }
  150. public function getBalconyAreaMin(): ?string
  151. {
  152. return $this->balconyAreaMin;
  153. }
  154. public function setBalconyAreaMin(?string $balconyAreaMin): self
  155. {
  156. $this->balconyAreaMin = $balconyAreaMin;
  157. return $this;
  158. }
  159. public function getBalconyAreaMax(): ?string
  160. {
  161. return $this->balconyAreaMax;
  162. }
  163. public function setBalconyAreaMax(?string $balconyAreaMax): self
  164. {
  165. $this->balconyAreaMax = $balconyAreaMax;
  166. return $this;
  167. }
  168. public function getCabinType(): ?CabinType
  169. {
  170. return $this->cabinType;
  171. }
  172. public function setCabinType(?CabinType $cabinType): self
  173. {
  174. $this->cabinType = $cabinType;
  175. return $this;
  176. }
  177. /**
  178. * @return Collection<int, CabinCategory>
  179. */
  180. public function getCabinCategories(): Collection
  181. {
  182. return $this->cabinCategories;
  183. }
  184. public function addCabinCategory(CabinCategory $cabinCategory): self
  185. {
  186. if (!$this->cabinCategories->contains($cabinCategory)) {
  187. $this->cabinCategories[] = $cabinCategory;
  188. $cabinCategory->setCabinSubType($this);
  189. }
  190. return $this;
  191. }
  192. public function removeCabinCategory(CabinCategory $cabinCategory): self
  193. {
  194. if ($this->cabinCategories->removeElement($cabinCategory)) {
  195. // set the owning side to null (unless already changed)
  196. if ($cabinCategory->getCabinSubType() === $this) {
  197. $cabinCategory->setCabinSubType(null);
  198. }
  199. }
  200. return $this;
  201. }
  202. public function getCompany(): ?Company
  203. {
  204. return $this->company;
  205. }
  206. public function setCompany(?Company $company): self
  207. {
  208. $this->company = $company;
  209. return $this;
  210. }
  211. /**
  212. * Method liée au Média Bundle
  213. */
  214. public function getMediaTagOwnerLabel(): ?string
  215. {
  216. return $this->getName() . ' (' . $this->getCompany()->getName() . ') [' . $this->getId() . ']';
  217. }
  218. /**
  219. * Method liée au Média Bundle
  220. * @return class-string
  221. */
  222. public function getFqcn(): string
  223. {
  224. return ClassUtils::getClass($this);
  225. }
  226. }