vendor/croisiland/common-bundle/src/Entity/Itinerary/Stopover.php line 34

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Itinerary;
  4. use Crea\MediaBundle\Entity\MediaTagOwnerInterface;
  5. use Crea\ParameterBundle\Entity\Parameter;
  6. use Crea\ToolsBundle\Entity\Geographic\Country;
  7. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  8. use Croisiland\CommonBundle\Annotation\Itinerary\ItineraryStopoverFormValidator;
  9. use Croisiland\CommonBundle\Entity\Correspondence\StopoverCorrespondence;
  10. use Croisiland\CommonBundle\Entity\Traits\ListOrderTrait;
  11. use Croisiland\CommonBundle\Repository\Itinerary\StopoverRepository;
  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. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  18. /**
  19. * @ItineraryStopoverFormValidator(groups="itinerary_stopover_form_validator")
  20. *
  21. * @UniqueEntity(
  22. * fields={"slug"},
  23. * errorPath="slug",
  24. * message="stopover.slug.unique_constraint",
  25. * ignoreNull=true
  26. * )
  27. *
  28. * @ORM\Entity(repositoryClass=StopoverRepository::class)
  29. */
  30. class Stopover implements MediaTagOwnerInterface
  31. {
  32. use ListOrderTrait;
  33. use LifecycleUserIdentifierTrait;
  34. /**
  35. * @ORM\Id
  36. *
  37. * @ORM\GeneratedValue
  38. *
  39. * @ORM\Column(type="integer")
  40. */
  41. private ?int $id = null;
  42. /**
  43. * @ORM\Column(type="string", length=255, nullable=true)
  44. */
  45. private ?string $name = null;
  46. /**
  47. * @Gedmo\Slug(fields={"name"}, updatable=false)
  48. *
  49. * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  50. */
  51. private ?string $slug = null;
  52. /**
  53. * @ORM\Column(type="boolean", nullable=false, options={"default" = false})
  54. */
  55. private bool $favorite = false;
  56. /**
  57. * @ORM\ManyToOne(targetEntity=Country::class)
  58. */
  59. private ?Country $country = null;
  60. /**
  61. * @ORM\Column(type="text", nullable=true)
  62. */
  63. private ?string $description = null;
  64. /**
  65. * @ORM\Column(type="text", nullable=true)
  66. */
  67. private ?string $whatToDo = null;
  68. /**
  69. * @ORM\Column(type="text", nullable=true)
  70. */
  71. private ?string $accessGuide = null;
  72. /**
  73. * @ORM\Column(type="float", nullable=true)
  74. */
  75. private ?float $latitude = null;
  76. /**
  77. * @ORM\Column(type="float", nullable=true)
  78. */
  79. private ?float $longitude = null;
  80. /**
  81. * @ORM\ManyToOne(targetEntity=Parameter::class)
  82. *
  83. * @ORM\JoinColumn(nullable=false)
  84. */
  85. private ?Parameter $creationOrigin = null;
  86. /**
  87. * @var Collection<int, StopoverCorrespondence>
  88. *
  89. * @ORM\OneToMany(targetEntity=StopoverCorrespondence::class, mappedBy="stopover", orphanRemoval=true, cascade={"remove"})
  90. */
  91. private $stopoverCorrespondences;
  92. /**
  93. * @var Collection<int, ItinerarySegment>
  94. *
  95. * @ORM\OneToMany(targetEntity=ItinerarySegment::class, mappedBy="stopover", orphanRemoval=true, cascade={"remove"})
  96. */
  97. private $itinerarySegments;
  98. /**
  99. * @ORM\OneToOne(targetEntity=StopoverComputed::class, mappedBy="stopover")
  100. */
  101. private ?StopoverComputed $computed = null;
  102. public function __construct()
  103. {
  104. $this->stopoverCorrespondences = new ArrayCollection();
  105. $this->itinerarySegments = new ArrayCollection();
  106. }
  107. public function getId(): ?int
  108. {
  109. return $this->id;
  110. }
  111. public function getName(): ?string
  112. {
  113. return $this->name;
  114. }
  115. public function setName(string $name): self
  116. {
  117. $this->name = $name;
  118. return $this;
  119. }
  120. public function getSlug(): ?string
  121. {
  122. return $this->slug;
  123. }
  124. public function setSlug(?string $slug): self
  125. {
  126. $this->slug = $slug;
  127. return $this;
  128. }
  129. public function isFavorite(): bool
  130. {
  131. return $this->favorite;
  132. }
  133. public function setFavorite(bool $favorite): Stopover
  134. {
  135. $this->favorite = $favorite;
  136. return $this;
  137. }
  138. public function getCountry(): ?Country
  139. {
  140. return $this->country;
  141. }
  142. public function setCountry(?Country $country): self
  143. {
  144. $this->country = $country;
  145. return $this;
  146. }
  147. public function getDescription(): ?string
  148. {
  149. return $this->description;
  150. }
  151. public function setDescription(?string $description): self
  152. {
  153. $this->description = $description;
  154. return $this;
  155. }
  156. public function getAccessGuide(): ?string
  157. {
  158. return $this->accessGuide;
  159. }
  160. public function setAccessGuide(?string $accessGuide): Stopover
  161. {
  162. $this->accessGuide = $accessGuide;
  163. return $this;
  164. }
  165. public function getWhatToDo(): ?string
  166. {
  167. return $this->whatToDo;
  168. }
  169. public function setWhatToDo(?string $whatToDo): Stopover
  170. {
  171. $this->whatToDo = $whatToDo;
  172. return $this;
  173. }
  174. public function getLatitude(): ?float
  175. {
  176. return $this->latitude;
  177. }
  178. public function setLatitude(?float $latitude): self
  179. {
  180. $this->latitude = $latitude;
  181. return $this;
  182. }
  183. public function getLongitude(): ?float
  184. {
  185. return $this->longitude;
  186. }
  187. public function setLongitude(?float $longitude): self
  188. {
  189. $this->longitude = $longitude;
  190. return $this;
  191. }
  192. public function getCreationOrigin(): ?Parameter
  193. {
  194. return $this->creationOrigin;
  195. }
  196. public function setCreationOrigin(?Parameter $creationOrigin): self
  197. {
  198. $this->creationOrigin = $creationOrigin;
  199. return $this;
  200. }
  201. /**
  202. * @return Collection<int, StopoverCorrespondence>
  203. */
  204. public function getStopoverCorrespondences(): Collection
  205. {
  206. return $this->stopoverCorrespondences;
  207. }
  208. public function addStopoverCorrespondence(StopoverCorrespondence $stopoverCorrespondence): self
  209. {
  210. if (!$this->stopoverCorrespondences->contains($stopoverCorrespondence)) {
  211. $this->stopoverCorrespondences[] = $stopoverCorrespondence;
  212. $stopoverCorrespondence->setStopover($this);
  213. }
  214. return $this;
  215. }
  216. public function removeStopoverCorrespondence(StopoverCorrespondence $stopoverCorrespondence): self
  217. {
  218. if ($this->stopoverCorrespondences->removeElement($stopoverCorrespondence)) {
  219. // set the owning side to null (unless already changed)
  220. if ($stopoverCorrespondence->getStopover() === $this) {
  221. $stopoverCorrespondence->setStopover(null);
  222. }
  223. }
  224. return $this;
  225. }
  226. /**
  227. * @return Collection<int, ItinerarySegment>
  228. */
  229. public function getItinerarySegments(): Collection
  230. {
  231. return $this->itinerarySegments;
  232. }
  233. public function addItinerarySegment(ItinerarySegment $itinerarySegment): self
  234. {
  235. if (!$this->itinerarySegments->contains($itinerarySegment)) {
  236. $this->itinerarySegments[] = $itinerarySegment;
  237. $itinerarySegment->setStopover($this);
  238. }
  239. return $this;
  240. }
  241. public function removeItinerarySegment(ItinerarySegment $itinerarySegment): self
  242. {
  243. if ($this->itinerarySegments->removeElement($itinerarySegment)) {
  244. // set the owning side to null (unless already changed)
  245. if ($itinerarySegment->getStopover() === $this) {
  246. $itinerarySegment->setStopover(null);
  247. }
  248. }
  249. return $this;
  250. }
  251. public function getComputed(): ?StopoverComputed
  252. {
  253. return $this->computed;
  254. }
  255. public function setComputed(?StopoverComputed $computed): Stopover
  256. {
  257. $this->computed = $computed;
  258. return $this;
  259. }
  260. /**
  261. * Method liée au Média Bundle
  262. */
  263. public function getMediaTagOwnerLabel(): ?string
  264. {
  265. return $this->getName();
  266. }
  267. /**
  268. * Method liée au Média Bundle
  269. * @return class-string
  270. */
  271. public function getFqcn(): string
  272. {
  273. return ClassUtils::getClass($this);
  274. }
  275. }