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

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Itinerary;
  4. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  5. use Croisiland\CommonBundle\Annotation\Itinerary\ItineraryFormValidator;
  6. use Croisiland\CommonBundle\Annotation\Itinerary\ItineraryFormDestinationValidator;
  7. use Croisiland\CommonBundle\Entity\Company\Company;
  8. use Croisiland\CommonBundle\Entity\Cruise\Cruise;
  9. use Croisiland\CommonBundle\Entity\Traits\IncludedExcludedTrait;
  10. use Croisiland\CommonBundle\Entity\Traits\IsActiveTrait;
  11. use Croisiland\CommonBundle\Repository\Itinerary\ItineraryRepository;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  16. /**
  17. * @ORM\Entity(repositoryClass=ItineraryRepository::class)
  18. *
  19. * @ItineraryFormValidator(groups={"itinerary_form_validator"})
  20. * @ItineraryFormDestinationValidator(groups={"itinerary_form_destination_validator"})
  21. *
  22. * @UniqueEntity(
  23. * fields={"code"},
  24. * errorPath="code",
  25. * message="itinerary.code.unique_constraint",
  26. * ignoreNull=true
  27. * )
  28. */
  29. class Itinerary implements ItineraryInterface
  30. {
  31. use IsActiveTrait;
  32. use LifecycleUserIdentifierTrait;
  33. use IncludedExcludedTrait;
  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="text", nullable=true)
  44. */
  45. private ?string $name = null;
  46. /**
  47. * @ORM\Column(type="text", nullable=true)
  48. */
  49. private ?string $description = null;
  50. /**
  51. * @ORM\Column(type="string", length=255, nullable=true)
  52. */
  53. private ?string $packageId = null;
  54. // TODO Supprimer Year, si inutilisée originellement dans l'entité flatfile liée a l'itinéraire dans le CMS
  55. /**
  56. * @ORM\Column(type="integer", nullable=true)
  57. */
  58. private ?int $year = null;
  59. // TODO Supprimer fromPrice, si inutilisée originellement dans l'entité flatfile liée a l'itinéraire dans le CMS
  60. /**
  61. * @ORM\Column(type="float", nullable=true)
  62. */
  63. private ?float $fromPrice = null;
  64. // TODO Supprimer ItineraryLength: aucune référence trouvée, et en doublon avec numberOfDays, et numberOfNights
  65. /**
  66. * @ORM\Column(type="integer", nullable=true)
  67. */
  68. private ?int $itineraryLength = null;
  69. /**
  70. * @ORM\Column(type="string", length=255, nullable=true)
  71. */
  72. private ?string $code = null;
  73. /**
  74. * @ORM\Column(type="string", length=1024, nullable=true)
  75. */
  76. private ?string $largeCode = null;
  77. /**
  78. * @ORM\Column(type="string", length=1020, nullable=true)
  79. */
  80. private ?string $originalName = null;
  81. /**
  82. * @ORM\Column(type="string", length=510, nullable=true)
  83. */
  84. private ?string $generatedName = null;
  85. /**
  86. * @ORM\Column(type="string", length=255, nullable=true)
  87. */
  88. private ?string $marketingName = null;
  89. /**
  90. * @ORM\Column(type="string", length=510, nullable=true)
  91. */
  92. private ?string $subTitle = null;
  93. /**
  94. * @ORM\Column(type="text", nullable=true)
  95. */
  96. private ?string $fluvialDescription = null;
  97. /**
  98. * @ORM\Column(type="smallint", nullable=true)
  99. */
  100. private ?int $numberOfDays = null;
  101. /**
  102. * @ORM\Column(type="smallint", nullable=true)
  103. */
  104. private ?int $numberOfNights = null;
  105. /**
  106. * @ORM\Column(type="boolean", nullable=false, options={"default" = false})
  107. */
  108. private bool $hasGroupDiscount = false;
  109. /**
  110. * @ORM\Column(type="boolean", nullable=false, options={"default" = false})
  111. */
  112. private bool $erpHistoryUpToDate = false;
  113. /**
  114. * @ORM\Column(type="boolean", nullable=false, options={"default" = false})
  115. */
  116. private bool $roundTrip = false;
  117. /**
  118. * @var Collection<int, ItinerarySegment>
  119. *
  120. * @ORM\OneToMany(targetEntity=ItinerarySegment::class, mappedBy="itinerary", orphanRemoval=true, cascade={"persist","remove"})
  121. *
  122. * @ORM\OrderBy({"segmentOrder" = "ASC"})
  123. */
  124. private Collection $itinerarySegments;
  125. /**
  126. * @ORM\ManyToOne(targetEntity=DestinationMain::class, inversedBy="itineraries")
  127. */
  128. private ?DestinationMain $destination = null;
  129. /**
  130. * @var Collection<int, ItinerarySecondaryDestination>
  131. *
  132. * @ORM\OneToMany(targetEntity=ItinerarySecondaryDestination::class, mappedBy="itinerary", orphanRemoval=true, cascade={"persist","remove"})
  133. *
  134. * @ORM\OrderBy({"position" = "ASC"})
  135. */
  136. private Collection $secondaryDestinations;
  137. /**
  138. * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="originatedItineraries")
  139. *
  140. * @ORM\JoinColumn(nullable=false)
  141. */
  142. private ?Company $originCompany = null;
  143. /**
  144. * @var Collection<int, Cruise>
  145. *
  146. * @ORM\OneToMany(targetEntity=Cruise::class, mappedBy="itinerary")
  147. *
  148. * @ORM\OrderBy({"departureDate" = "ASC"})
  149. */
  150. private Collection $cruises;
  151. /**
  152. * @ORM\OneToOne(targetEntity=ItineraryComputed::class, mappedBy="itinerary")
  153. */
  154. private ?ItineraryComputed $computed = null;
  155. /**
  156. * @var Collection<int, ItineraryActivity>
  157. *
  158. * @ORM\OneToMany(targetEntity=ItineraryActivity::class, mappedBy="itinerary", orphanRemoval=true, cascade={"persist","remove"})
  159. *
  160. * @ORM\OrderBy({"listOrder" = "ASC"})
  161. */
  162. private Collection $itineraryActivities;
  163. /**
  164. * @var Collection<int, ItineraryConsistencyReport>
  165. *
  166. * @ORM\OneToMany(targetEntity="Croisiland\CommonBundle\Entity\Itinerary\ItineraryConsistencyReport", fetch="LAZY", mappedBy="itinerary", cascade={"persist"}, orphanRemoval=true)
  167. * @ORM\OrderBy({"createdAt" = "DESC"})
  168. */
  169. private Collection $consistencyReports;
  170. /**
  171. * @ORM\Column(type="integer", nullable=true)
  172. */
  173. private ?int $consistencyScore = null;
  174. public function __construct()
  175. {
  176. $this->itinerarySegments = new ArrayCollection();
  177. $this->secondaryDestinations = new ArrayCollection();
  178. $this->cruises = new ArrayCollection();
  179. $this->itineraryActivities = new ArrayCollection();
  180. $this->consistencyReports = new ArrayCollection();
  181. }
  182. public function getId(): ?int
  183. {
  184. return $this->id;
  185. }
  186. public function setId(int $id): Itinerary
  187. {
  188. $this->id = $id;
  189. return $this;
  190. }
  191. public function getName(): ?string
  192. {
  193. return $this->name;
  194. }
  195. public function setName(?string $name): self
  196. {
  197. $this->name = $name;
  198. return $this;
  199. }
  200. public function getDescription(): ?string
  201. {
  202. return $this->description;
  203. }
  204. public function setDescription(?string $description): self
  205. {
  206. $this->description = $description;
  207. return $this;
  208. }
  209. public function getPackageId(): ?string
  210. {
  211. return $this->packageId;
  212. }
  213. public function setPackageId(?string $packageId): self
  214. {
  215. $this->packageId = $packageId;
  216. return $this;
  217. }
  218. public function getYear(): ?int
  219. {
  220. return $this->year;
  221. }
  222. public function setYear(?int $year): self
  223. {
  224. $this->year = $year;
  225. return $this;
  226. }
  227. public function getFromPrice(): ?float
  228. {
  229. return $this->fromPrice;
  230. }
  231. public function setFromPrice(?float $fromPrice): self
  232. {
  233. $this->fromPrice = $fromPrice;
  234. return $this;
  235. }
  236. public function getItineraryLength(): ?int
  237. {
  238. return $this->itineraryLength;
  239. }
  240. public function setItineraryLength(?int $itineraryLength): self
  241. {
  242. $this->itineraryLength = $itineraryLength;
  243. return $this;
  244. }
  245. public function getCode(): ?string
  246. {
  247. return $this->code;
  248. }
  249. public function setCode(?string $code): Itinerary
  250. {
  251. $this->code = $code;
  252. return $this;
  253. }
  254. public function getLargeCode(): ?string
  255. {
  256. return $this->largeCode;
  257. }
  258. public function setLargeCode(?string $largeCode): Itinerary
  259. {
  260. $this->largeCode = $largeCode;
  261. return $this;
  262. }
  263. public function getOriginalName(): ?string
  264. {
  265. return $this->originalName;
  266. }
  267. public function setOriginalName(?string $originalName): Itinerary
  268. {
  269. $this->originalName = $originalName;
  270. return $this;
  271. }
  272. public function getGeneratedName(): ?string
  273. {
  274. return $this->generatedName;
  275. }
  276. public function setGeneratedName(?string $generatedName): Itinerary
  277. {
  278. $this->generatedName = $generatedName;
  279. return $this;
  280. }
  281. public function getMarketingName(): ?string
  282. {
  283. return $this->marketingName;
  284. }
  285. public function setMarketingName(?string $marketingName): Itinerary
  286. {
  287. $this->marketingName = $marketingName;
  288. return $this;
  289. }
  290. public function getSubTitle(): ?string
  291. {
  292. return $this->subTitle;
  293. }
  294. public function setSubTitle(?string $subTitle): Itinerary
  295. {
  296. $this->subTitle = $subTitle;
  297. return $this;
  298. }
  299. public function getFluvialDescription(): ?string
  300. {
  301. return $this->fluvialDescription;
  302. }
  303. public function setFluvialDescription(?string $fluvialDescription): Itinerary
  304. {
  305. $this->fluvialDescription = $fluvialDescription;
  306. return $this;
  307. }
  308. public function getNumberOfDays(): ?int
  309. {
  310. return $this->numberOfDays;
  311. }
  312. public function setNumberOfDays(?int $numberOfDays): Itinerary
  313. {
  314. $this->numberOfDays = $numberOfDays;
  315. return $this;
  316. }
  317. public function getNumberOfNights(): ?int
  318. {
  319. return $this->numberOfNights;
  320. }
  321. public function setNumberOfNights(?int $numberOfNights): Itinerary
  322. {
  323. $this->numberOfNights = $numberOfNights;
  324. return $this;
  325. }
  326. public function isHasGroupDiscount(): bool
  327. {
  328. return $this->hasGroupDiscount;
  329. }
  330. public function setHasGroupDiscount(bool $hasGroupDiscount): Itinerary
  331. {
  332. $this->hasGroupDiscount = $hasGroupDiscount;
  333. return $this;
  334. }
  335. public function isErpHistoryUpToDate(): bool
  336. {
  337. return $this->erpHistoryUpToDate;
  338. }
  339. public function setErpHistoryUpToDate(bool $erpHistoryUpToDate): Itinerary
  340. {
  341. $this->erpHistoryUpToDate = $erpHistoryUpToDate;
  342. return $this;
  343. }
  344. public function isRoundTrip(): bool
  345. {
  346. return $this->roundTrip;
  347. }
  348. public function setRoundTrip(bool $roundTrip): Itinerary
  349. {
  350. $this->roundTrip = $roundTrip;
  351. return $this;
  352. }
  353. /**
  354. * @return Collection<int, ItinerarySegment> <p>Ordered by SegmentOrder</p>
  355. */
  356. public function getItinerarySegments(): Collection
  357. {
  358. return $this->itinerarySegments;
  359. }
  360. public function addItinerarySegment(ItinerarySegment $itinerarySegment): self
  361. {
  362. if ($this->itinerarySegments->contains($itinerarySegment)) {
  363. return $this;
  364. }
  365. $itinerarySegment->setItinerary($this);
  366. $this->itinerarySegments[] = $itinerarySegment;
  367. return $this;
  368. }
  369. public function removeItinerarySegment(ItinerarySegment $itinerarySegment): self
  370. {
  371. if ($this->itinerarySegments->removeElement($itinerarySegment)) {
  372. // set the owning side to null (unless already changed)
  373. if ($itinerarySegment->getItinerary() === $this) {
  374. $itinerarySegment->setItinerary(null);
  375. }
  376. }
  377. return $this;
  378. }
  379. public function getDestination(): ?DestinationMain
  380. {
  381. return $this->destination;
  382. }
  383. public function setDestination(?DestinationMain $destination): self
  384. {
  385. $this->destination = $destination;
  386. return $this;
  387. }
  388. /**
  389. * @return Collection<int, ItinerarySecondaryDestination>
  390. */
  391. public function getSecondaryDestinations(): Collection
  392. {
  393. return $this->secondaryDestinations;
  394. }
  395. public function addSecondaryDestination(ItinerarySecondaryDestination $secondaryDestination): self
  396. {
  397. if ($this->secondaryDestinations->contains($secondaryDestination)) {
  398. return $this;
  399. }
  400. $secondaryDestination->setItinerary($this);
  401. $this->secondaryDestinations[] = $secondaryDestination;
  402. return $this;
  403. }
  404. public function removeSecondaryDestination(ItinerarySecondaryDestination $secondaryDestination): self
  405. {
  406. if ($this->secondaryDestinations->removeElement($secondaryDestination)) {
  407. // set the owning side to null (unless already changed)
  408. if ($secondaryDestination->getItinerary() === $this) {
  409. $secondaryDestination->setItinerary(null);
  410. }
  411. }
  412. return $this;
  413. }
  414. /**
  415. * @return Collection<int, Cruise>
  416. */
  417. public function getCruises(): Collection
  418. {
  419. return $this->cruises;
  420. }
  421. public function addCruise(Cruise $cruise): self
  422. {
  423. if (!$this->cruises->contains($cruise)) {
  424. $this->cruises[] = $cruise;
  425. $cruise->setItinerary($this);
  426. }
  427. return $this;
  428. }
  429. public function removeCruise(Cruise $cruise): self
  430. {
  431. if ($this->cruises->removeElement($cruise)) {
  432. // set the owning side to null (unless already changed)
  433. if ($cruise->getItinerary() === $this) {
  434. $cruise->setItinerary(null);
  435. }
  436. }
  437. return $this;
  438. }
  439. public function getOriginCompany(): ?Company
  440. {
  441. return $this->originCompany;
  442. }
  443. public function setOriginCompany(?Company $originCompany): self
  444. {
  445. $this->originCompany = $originCompany;
  446. return $this;
  447. }
  448. public function getItineraryComputed(): ?ItineraryComputed
  449. {
  450. return $this->computed;
  451. }
  452. public function setItineraryComputed(?ItineraryComputed $computed): void
  453. {
  454. $this->computed = $computed;
  455. }
  456. /**
  457. * @return Collection<int, ItineraryActivity> <p>Ordered by ListOrder</p>
  458. */
  459. public function getItineraryActivities(): Collection
  460. {
  461. return $this->itineraryActivities;
  462. }
  463. public function addItineraryActivity(ItineraryActivity $itineraryActivity): self
  464. {
  465. if ($this->itineraryActivities->contains($itineraryActivity)) {
  466. return $this;
  467. }
  468. $itineraryActivity->setItinerary($this);
  469. $this->itineraryActivities[] = $itineraryActivity;
  470. return $this;
  471. }
  472. public function removeItineraryActivity(ItineraryActivity $itineraryActivity): self
  473. {
  474. if ($this->itineraryActivities->removeElement($itineraryActivity)) {
  475. // set the owning side to null (unless already changed)
  476. if ($itineraryActivity->getItinerary() === $this) {
  477. $itineraryActivity->setItinerary(null);
  478. }
  479. }
  480. return $this;
  481. }
  482. public function getConsistencyReports(): Collection
  483. {
  484. return $this->consistencyReports;
  485. }
  486. public function addConsistencyReport(ItineraryConsistencyReport $report): self
  487. {
  488. if (!$this->consistencyReports->contains($report)) {
  489. $this->consistencyReports[] = $report;
  490. $report->setItinerary($this);
  491. }
  492. return $this;
  493. }
  494. public function removeConsistencyReport(ItineraryConsistencyReport $report): self
  495. {
  496. if ($this->consistencyReports->removeElement($report)) {
  497. if ($report->getItinerary() === $this) {
  498. $report->setItinerary(null);
  499. }
  500. }
  501. return $this;
  502. }
  503. public function getConsistencyScore(): ?int
  504. {
  505. return $this->consistencyScore;
  506. }
  507. public function setConsistencyScore(?int $consistencyScore): self
  508. {
  509. $this->consistencyScore = $consistencyScore;
  510. return $this;
  511. }
  512. }