vendor/croisiland/common-bundle/src/Entity/Cruise/Cruise.php line 36

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Cruise;
  4. use Crea\ParameterBundle\Entity\Parameter;
  5. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  6. use Croisiland\CommonBundle\Annotation\Cruise\CruiseFormValidator;
  7. use Croisiland\CommonBundle\Entity\Itinerary\Itinerary;
  8. use Croisiland\CommonBundle\Entity\Offer\OfferCruise;
  9. use Croisiland\CommonBundle\Entity\Price\Price;
  10. use Croisiland\CommonBundle\Entity\Ship\Ship;
  11. use Croisiland\CommonBundle\Entity\Traits\IncludedExcludedTrait;
  12. use Croisiland\CommonBundle\Entity\Traits\IsActiveTrait;
  13. use Croisiland\CommonBundle\Entity\Traits\IsVisibleTrait;
  14. use Croisiland\CommonBundle\Entity\Traits\ModuleOrderTrait;
  15. use Croisiland\CommonBundle\Repository\Cruise\CruiseRepository;
  16. use Doctrine\Common\Collections\ArrayCollection;
  17. use Doctrine\Common\Collections\Collection;
  18. use Doctrine\ORM\Mapping as ORM;
  19. use Gedmo\Mapping\Annotation as Gedmo;
  20. /**
  21. * @CruiseFormValidator(groups="cruise_form_validator")
  22. *
  23. * @ORM\Entity(repositoryClass=CruiseRepository::class)
  24. *
  25. * @ORM\Table(
  26. * indexes={
  27. *
  28. * @ORM\Index(name="idx_cruise_itinerary_departure_date", fields={"itinerary", "departureDate"})
  29. * }
  30. * )
  31. */
  32. class Cruise implements CruiseInterface
  33. {
  34. // TODO: propriétés à vérifier
  35. // private ?string $paymentsWithoutCharge = null;
  36. use IsActiveTrait;
  37. use IsVisibleTrait;
  38. use LifecycleUserIdentifierTrait;
  39. use ModuleOrderTrait;
  40. use IncludedExcludedTrait;
  41. /**
  42. * @ORM\Id
  43. *
  44. * @ORM\GeneratedValue
  45. *
  46. * @ORM\Column(type="integer")
  47. */
  48. private ?int $id = null;
  49. /**
  50. * @ORM\Column(type="string", length=255)
  51. */
  52. private ?string $name = null;
  53. /**
  54. * @ORM\Column(type="string", length=255, nullable=true)
  55. */
  56. private ?string $code = null;
  57. /**
  58. * @ORM\Column(type="boolean", nullable=false, options={"default" = false})
  59. */
  60. private bool $crush = false;
  61. /**
  62. * @Gedmo\Slug(fields={"name"}, updatable=false)
  63. *
  64. * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  65. */
  66. private ?string $slug = null;
  67. /**
  68. * @ORM\Column(type="text", nullable=true)
  69. */
  70. private ?string $flatFileDescription = null;
  71. /**
  72. * todo: vérifier si nullable=true est nécessaire et valeur par défaut.
  73. *
  74. * @ORM\Column(type="boolean", nullable=true)
  75. */
  76. private ?bool $flatFileImmediateConfirm = null;
  77. /**
  78. * @ORM\ManyToOne(targetEntity=Ship::class, inversedBy="cruises")
  79. *
  80. * @ORM\JoinColumn(nullable=false)
  81. */
  82. private ?Ship $ship = null;
  83. /**
  84. * @ORM\Column(type="boolean", nullable=false, options={"default" = false})
  85. */
  86. private bool $manuallyCreated = false;
  87. /**
  88. * @ORM\Column(type="date")
  89. */
  90. private ?\DateTimeInterface $departureDate = null;
  91. /**
  92. * @ORM\Column(type="date")
  93. */
  94. private ?\DateTimeInterface $arrivalDate = null;
  95. /**
  96. * @var Collection<int, Price>
  97. *
  98. * @ORM\OneToMany(targetEntity=Price::class, mappedBy="cruise", orphanRemoval=true)
  99. */
  100. private Collection $prices;
  101. /**
  102. * @ORM\ManyToOne(targetEntity=Price::class)
  103. *
  104. * @ORM\JoinColumn(onDelete="SET NULL")
  105. */
  106. private ?Price $bestPrice = null;
  107. /**
  108. * @ORM\ManyToOne(targetEntity=Price::class)
  109. *
  110. * @ORM\JoinColumn(onDelete="SET NULL")
  111. */
  112. private ?Price $bestPriceWithFlight = null;
  113. /**
  114. * @ORM\ManyToOne(targetEntity=Price::class)
  115. *
  116. * @ORM\JoinColumn(onDelete="SET NULL")
  117. */
  118. private ?Price $bestGroupPrice = null;
  119. /**
  120. * @ORM\ManyToOne(targetEntity=Price::class)
  121. *
  122. * @ORM\JoinColumn(onDelete="SET NULL")
  123. */
  124. private ?Price $bestGroupPriceWithFlight = null;
  125. /**
  126. * @ORM\ManyToOne(targetEntity=Itinerary::class, inversedBy="cruises")
  127. *
  128. * @ORM\JoinColumn(nullable=false)
  129. */
  130. private ?Itinerary $itinerary = null;
  131. /**
  132. * @var Collection<int, TagCruise>
  133. *
  134. * @ORM\OneToMany(targetEntity=TagCruise::class, mappedBy="cruise", orphanRemoval=true, cascade={"persist"})
  135. * @ORM\OrderBy({"listOrder" = "ASC"})
  136. */
  137. private Collection $tagCruises;
  138. /**
  139. * @var Collection<int, OfferCruise>
  140. *
  141. * @ORM\OneToMany(targetEntity=OfferCruise::class, mappedBy="cruise", orphanRemoval=true, cascade={"persist"})
  142. */
  143. private Collection $offerCruises;
  144. /**
  145. * @ORM\Column(type="boolean", nullable=false, options={"default" = false})
  146. */
  147. private bool $isErpItineraryHistoryUpToDate = false;
  148. /**
  149. * @ORM\ManyToOne(targetEntity=Parameter::class)
  150. *
  151. * @ORM\JoinColumn(nullable=true)
  152. */
  153. private ?Parameter $origin = null;
  154. public function __construct()
  155. {
  156. $this->prices = new ArrayCollection();
  157. $this->tagCruises = new ArrayCollection();
  158. $this->offerCruises = new ArrayCollection();
  159. }
  160. public function getId(): ?int
  161. {
  162. return $this->id;
  163. }
  164. public function getName(): ?string
  165. {
  166. return $this->name;
  167. }
  168. public function setName(?string $name): self
  169. {
  170. $this->name = $name;
  171. return $this;
  172. }
  173. public function getCode(): ?string
  174. {
  175. return $this->code;
  176. }
  177. public function setCode(?string $code): self
  178. {
  179. $this->code = $code;
  180. return $this;
  181. }
  182. public function isCrush(): ?bool
  183. {
  184. return $this->crush;
  185. }
  186. public function setCrush(bool $crush): self
  187. {
  188. $this->crush = $crush;
  189. return $this;
  190. }
  191. public function getSlug(): ?string
  192. {
  193. return $this->slug;
  194. }
  195. public function setSlug(?string $slug): self
  196. {
  197. $this->slug = $slug;
  198. return $this;
  199. }
  200. public function getFlatFileDescription(): ?string
  201. {
  202. return $this->flatFileDescription;
  203. }
  204. public function setFlatFileDescription(string $flatFileDescription): self
  205. {
  206. $this->flatFileDescription = $flatFileDescription;
  207. return $this;
  208. }
  209. public function isFlatFileImmediateConfirm(): ?bool
  210. {
  211. return $this->flatFileImmediateConfirm;
  212. }
  213. public function setFlatFileImmediateConfirm(?bool $flatFileImmediateConfirm): self
  214. {
  215. $this->flatFileImmediateConfirm = $flatFileImmediateConfirm;
  216. return $this;
  217. }
  218. public function getShip(): ?Ship
  219. {
  220. return $this->ship;
  221. }
  222. public function setShip(?Ship $ship): self
  223. {
  224. $this->ship = $ship;
  225. return $this;
  226. }
  227. public function isManuallyCreated(): ?bool
  228. {
  229. return $this->manuallyCreated;
  230. }
  231. public function setManuallyCreated(bool $manuallyCreated): self
  232. {
  233. $this->manuallyCreated = $manuallyCreated;
  234. return $this;
  235. }
  236. public function getDepartureDate(): ?\DateTimeInterface
  237. {
  238. return $this->departureDate;
  239. }
  240. public function setDepartureDate(?\DateTimeInterface $departureDate): self
  241. {
  242. $this->departureDate = $departureDate;
  243. return $this;
  244. }
  245. public function getArrivalDate(): ?\DateTimeInterface
  246. {
  247. return $this->arrivalDate;
  248. }
  249. public function setArrivalDate(?\DateTimeInterface $arrivalDate): self
  250. {
  251. $this->arrivalDate = $arrivalDate;
  252. return $this;
  253. }
  254. /**
  255. * @return Collection<int, Price>
  256. */
  257. public function getPrices(): Collection
  258. {
  259. return $this->prices;
  260. }
  261. public function addPrice(Price $price): self
  262. {
  263. if (!$this->prices->contains($price)) {
  264. $this->prices[] = $price;
  265. $price->setCruise($this);
  266. }
  267. return $this;
  268. }
  269. public function removePrice(Price $price): self
  270. {
  271. if ($this->prices->removeElement($price)) {
  272. // set the owning side to null (unless already changed)
  273. if ($price->getCruise() === $this) {
  274. $price->setCruise(null);
  275. }
  276. }
  277. return $this;
  278. }
  279. public function getBestPrice(): ?Price
  280. {
  281. return $this->bestPrice;
  282. }
  283. public function setBestPrice(?Price $bestPrice): self
  284. {
  285. $this->bestPrice = $bestPrice;
  286. return $this;
  287. }
  288. public function getBestPriceWithFlight(): ?Price
  289. {
  290. return $this->bestPriceWithFlight;
  291. }
  292. public function setBestPriceWithFlight(?Price $bestPriceWithFlight): self
  293. {
  294. $this->bestPriceWithFlight = $bestPriceWithFlight;
  295. return $this;
  296. }
  297. public function getBestGroupPrice(): ?Price
  298. {
  299. return $this->bestGroupPrice;
  300. }
  301. public function setBestGroupPrice(?Price $bestGroupPrice): self
  302. {
  303. $this->bestGroupPrice = $bestGroupPrice;
  304. return $this;
  305. }
  306. public function getBestGroupPriceWithFlight(): ?Price
  307. {
  308. return $this->bestGroupPriceWithFlight;
  309. }
  310. public function setBestGroupPriceWithFlight(?Price $bestGroupPriceWithFlight): self
  311. {
  312. $this->bestGroupPriceWithFlight = $bestGroupPriceWithFlight;
  313. return $this;
  314. }
  315. /**
  316. * @return Collection<int, TagCruise>
  317. */
  318. public function getTagCruises(): Collection
  319. {
  320. return $this->tagCruises;
  321. }
  322. public function addTagCruise(TagCruise $tagCruise): self
  323. {
  324. if (!$this->tagCruises->contains($tagCruise)) {
  325. $this->tagCruises[] = $tagCruise;
  326. $tagCruise->setCruise($this);
  327. }
  328. return $this;
  329. }
  330. public function removeTagCruise(TagCruise $tagCruise): self
  331. {
  332. if ($this->tagCruises->removeElement($tagCruise)) {
  333. // set the owning side to null (unless already changed)
  334. if ($tagCruise->getCruise() === $this) {
  335. $tagCruise->setCruise(null);
  336. }
  337. }
  338. return $this;
  339. }
  340. /**
  341. * @return Collection<int, OfferCruise>
  342. */
  343. public function getOfferCruises(): Collection
  344. {
  345. return $this->offerCruises;
  346. }
  347. public function addOfferCruise(OfferCruise $offerCruise): self
  348. {
  349. if (!$this->offerCruises->contains($offerCruise)) {
  350. $this->offerCruises[] = $offerCruise;
  351. $offerCruise->setCruise($this);
  352. }
  353. return $this;
  354. }
  355. public function removeOfferCruise(OfferCruise $offerCruise): self
  356. {
  357. if ($this->offerCruises->removeElement($offerCruise)) {
  358. // set the owning side to null (unless already changed)
  359. if ($offerCruise->getCruise() === $this) {
  360. $offerCruise->setCruise(null);
  361. }
  362. }
  363. return $this;
  364. }
  365. public function getItinerary(): ?Itinerary
  366. {
  367. return $this->itinerary;
  368. }
  369. public function setItinerary(?Itinerary $itinerary): self
  370. {
  371. $this->itinerary = $itinerary;
  372. return $this;
  373. }
  374. public function isErpItineraryHistoryUpToDate(): bool
  375. {
  376. return $this->isErpItineraryHistoryUpToDate;
  377. }
  378. public function setIsErpItineraryHistoryUpToDate(bool $isErpItineraryHistoryUpToDate): self
  379. {
  380. $this->isErpItineraryHistoryUpToDate = $isErpItineraryHistoryUpToDate;
  381. return $this;
  382. }
  383. /**
  384. * @return Parameter|null
  385. */
  386. public function getOrigin(): ?Parameter
  387. {
  388. return $this->origin;
  389. }
  390. /**
  391. * @param Parameter|null $origin
  392. * @return Cruise
  393. */
  394. public function setOrigin(?Parameter $origin): Cruise
  395. {
  396. $this->origin = $origin;
  397. return $this;
  398. }
  399. }