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

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Itinerary;
  4. use Croisiland\CommonBundle\Annotation\Itinerary\ItineraryDestinationMainFormValidator;
  5. use Croisiland\CommonBundle\Entity\Correspondence\DestinationCorrespondence;
  6. // --> use Croisiland\CommonBundle\EntityView\Itinerary\ViewDestinationMainRelationsCounts;
  7. use Croisiland\CommonBundle\Repository\Itinerary\DestinationMainRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. /**
  12. * @ItineraryDestinationMainFormValidator(groups={"itinerary_destination_main_form_validator"})
  13. *
  14. * @ORM\Entity(repositoryClass=DestinationMainRepository::class)
  15. */
  16. class DestinationMain extends Destination
  17. {
  18. /**
  19. * @var Collection<int, DestinationSecondary>
  20. *
  21. * @ORM\OneToMany(targetEntity=DestinationSecondary::class, mappedBy="mainDestination", cascade={"persist"})
  22. */
  23. private $secondaryDestinations;
  24. /**
  25. * @var Collection<int, DestinationCorrespondence>
  26. *
  27. * @ORM\OneToMany(targetEntity=DestinationCorrespondence::class, mappedBy="destination", orphanRemoval=true)
  28. */
  29. private $destinationCorrespondences;
  30. /**
  31. * @var Collection<int, Itinerary>
  32. *
  33. * @ORM\OneToMany(targetEntity=Itinerary::class, mappedBy="destination")
  34. */
  35. private $itineraries;
  36. /**
  37. * @ORM\OneToOne(targetEntity=DestinationMainComputed::class, mappedBy="destinationMain")
  38. */
  39. private ?DestinationMainComputed $computed = null;
  40. public function __construct()
  41. {
  42. parent::__construct();
  43. $this->secondaryDestinations = new ArrayCollection();
  44. $this->destinationCorrespondences = new ArrayCollection();
  45. $this->itineraries = new ArrayCollection();
  46. }
  47. /**
  48. * @return Collection<int, DestinationSecondary>
  49. */
  50. public function getSecondaryDestinations(): Collection
  51. {
  52. return $this->secondaryDestinations;
  53. }
  54. public function addSecondaryDestination(DestinationSecondary $secondaryDestination): self
  55. {
  56. if (!$this->secondaryDestinations->contains($secondaryDestination)) {
  57. $this->secondaryDestinations[] = $secondaryDestination;
  58. $secondaryDestination->setMainDestination($this);
  59. }
  60. return $this;
  61. }
  62. public function removeSecondaryDestination(DestinationSecondary $secondaryDestination): self
  63. {
  64. if ($this->secondaryDestinations->removeElement($secondaryDestination)) {
  65. // set the owning side to null (unless already changed)
  66. if ($secondaryDestination->getMainDestination() === $this) {
  67. $secondaryDestination->setMainDestination(null);
  68. }
  69. }
  70. return $this;
  71. }
  72. /**
  73. * @return Collection<int, DestinationCorrespondence>
  74. */
  75. public function getDestinationCorrespondences(): Collection
  76. {
  77. return $this->destinationCorrespondences;
  78. }
  79. public function addDestinationCorrespondence(DestinationCorrespondence $destinationCorrespondence): self
  80. {
  81. if (!$this->destinationCorrespondences->contains($destinationCorrespondence)) {
  82. $this->destinationCorrespondences[] = $destinationCorrespondence;
  83. $destinationCorrespondence->setDestination($this);
  84. }
  85. return $this;
  86. }
  87. public function removeDestinationCorrespondence(DestinationCorrespondence $destinationCorrespondence): self
  88. {
  89. if ($this->destinationCorrespondences->removeElement($destinationCorrespondence)) {
  90. // set the owning side to null (unless already changed)
  91. if ($destinationCorrespondence->getDestination() === $this) {
  92. $destinationCorrespondence->setDestination(null);
  93. }
  94. }
  95. return $this;
  96. }
  97. /**
  98. * @return Collection<int, Itinerary>
  99. */
  100. public function getItineraries(): Collection
  101. {
  102. return $this->itineraries;
  103. }
  104. public function addItinerary(Itinerary $itinerary): self
  105. {
  106. if (!$this->itineraries->contains($itinerary)) {
  107. $this->itineraries[] = $itinerary;
  108. $itinerary->setDestination($this);
  109. }
  110. return $this;
  111. }
  112. public function removeItinerary(Itinerary $itinerary): self
  113. {
  114. if ($this->itineraries->removeElement($itinerary)) {
  115. // set the owning side to null (unless already changed)
  116. if ($itinerary->getDestination() === $this) {
  117. $itinerary->setDestination(null);
  118. }
  119. }
  120. return $this;
  121. }
  122. public function getComputed(): ?DestinationMainComputed
  123. {
  124. return $this->computed;
  125. }
  126. public function setComputed(?DestinationMainComputed $computed): DestinationMain
  127. {
  128. $this->computed = $computed;
  129. return $this;
  130. }
  131. // public function getNeedSearchDataUpdate(): ?bool
  132. // {
  133. // return $this->needSearchDataUpdate;
  134. // }
  135. //
  136. // public function setNeedSearchDataUpdate(bool $needSearchDataUpdate): self
  137. // {
  138. // $this->needSearchDataUpdate = $needSearchDataUpdate;
  139. //
  140. // return $this;
  141. // }
  142. }