<?php
declare(strict_types=1);
namespace Croisiland\CommonBundle\Entity\Itinerary;
use Croisiland\CommonBundle\Annotation\Itinerary\ItineraryDestinationMainFormValidator;
use Croisiland\CommonBundle\Entity\Correspondence\DestinationCorrespondence;
// --> use Croisiland\CommonBundle\EntityView\Itinerary\ViewDestinationMainRelationsCounts;
use Croisiland\CommonBundle\Repository\Itinerary\DestinationMainRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ItineraryDestinationMainFormValidator(groups={"itinerary_destination_main_form_validator"})
*
* @ORM\Entity(repositoryClass=DestinationMainRepository::class)
*/
class DestinationMain extends Destination
{
/**
* @var Collection<int, DestinationSecondary>
*
* @ORM\OneToMany(targetEntity=DestinationSecondary::class, mappedBy="mainDestination", cascade={"persist"})
*/
private $secondaryDestinations;
/**
* @var Collection<int, DestinationCorrespondence>
*
* @ORM\OneToMany(targetEntity=DestinationCorrespondence::class, mappedBy="destination", orphanRemoval=true)
*/
private $destinationCorrespondences;
/**
* @var Collection<int, Itinerary>
*
* @ORM\OneToMany(targetEntity=Itinerary::class, mappedBy="destination")
*/
private $itineraries;
/**
* @ORM\OneToOne(targetEntity=DestinationMainComputed::class, mappedBy="destinationMain")
*/
private ?DestinationMainComputed $computed = null;
public function __construct()
{
parent::__construct();
$this->secondaryDestinations = new ArrayCollection();
$this->destinationCorrespondences = new ArrayCollection();
$this->itineraries = new ArrayCollection();
}
/**
* @return Collection<int, DestinationSecondary>
*/
public function getSecondaryDestinations(): Collection
{
return $this->secondaryDestinations;
}
public function addSecondaryDestination(DestinationSecondary $secondaryDestination): self
{
if (!$this->secondaryDestinations->contains($secondaryDestination)) {
$this->secondaryDestinations[] = $secondaryDestination;
$secondaryDestination->setMainDestination($this);
}
return $this;
}
public function removeSecondaryDestination(DestinationSecondary $secondaryDestination): self
{
if ($this->secondaryDestinations->removeElement($secondaryDestination)) {
// set the owning side to null (unless already changed)
if ($secondaryDestination->getMainDestination() === $this) {
$secondaryDestination->setMainDestination(null);
}
}
return $this;
}
/**
* @return Collection<int, DestinationCorrespondence>
*/
public function getDestinationCorrespondences(): Collection
{
return $this->destinationCorrespondences;
}
public function addDestinationCorrespondence(DestinationCorrespondence $destinationCorrespondence): self
{
if (!$this->destinationCorrespondences->contains($destinationCorrespondence)) {
$this->destinationCorrespondences[] = $destinationCorrespondence;
$destinationCorrespondence->setDestination($this);
}
return $this;
}
public function removeDestinationCorrespondence(DestinationCorrespondence $destinationCorrespondence): self
{
if ($this->destinationCorrespondences->removeElement($destinationCorrespondence)) {
// set the owning side to null (unless already changed)
if ($destinationCorrespondence->getDestination() === $this) {
$destinationCorrespondence->setDestination(null);
}
}
return $this;
}
/**
* @return Collection<int, Itinerary>
*/
public function getItineraries(): Collection
{
return $this->itineraries;
}
public function addItinerary(Itinerary $itinerary): self
{
if (!$this->itineraries->contains($itinerary)) {
$this->itineraries[] = $itinerary;
$itinerary->setDestination($this);
}
return $this;
}
public function removeItinerary(Itinerary $itinerary): self
{
if ($this->itineraries->removeElement($itinerary)) {
// set the owning side to null (unless already changed)
if ($itinerary->getDestination() === $this) {
$itinerary->setDestination(null);
}
}
return $this;
}
public function getComputed(): ?DestinationMainComputed
{
return $this->computed;
}
public function setComputed(?DestinationMainComputed $computed): DestinationMain
{
$this->computed = $computed;
return $this;
}
// public function getNeedSearchDataUpdate(): ?bool
// {
// return $this->needSearchDataUpdate;
// }
//
// public function setNeedSearchDataUpdate(bool $needSearchDataUpdate): self
// {
// $this->needSearchDataUpdate = $needSearchDataUpdate;
//
// return $this;
// }
}