<?php
declare(strict_types=1);
namespace Croisiland\CommonBundle\Entity\Itinerary;
use Croisiland\CommonBundle\Annotation\Itinerary\ItineraryDestinationSecondaryFormValidator;
use Croisiland\CommonBundle\Entity\Correspondence\DestinationCorrespondence;
use Croisiland\CommonBundle\Repository\Itinerary\DestinationSecondaryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ItineraryDestinationSecondaryFormValidator(groups="itinerary_destination_secondary_form_validator")
*
* @ORM\Entity(repositoryClass=DestinationSecondaryRepository::class)
*/
class DestinationSecondary extends Destination
{
/**
* @ORM\ManyToOne(targetEntity=DestinationMain::class, inversedBy="secondaryDestinations")
*/
private ?DestinationMain $mainDestination = null;
/**
* @var Collection<int, ItinerarySecondaryDestination>
*
* @ORM\OneToMany(targetEntity=ItinerarySecondaryDestination::class, mappedBy="secondaryDestination", orphanRemoval=true)
*/
private $itineraryRelations;
/**
* @var Collection<int, DestinationCorrespondence>
*
* @ORM\OneToMany(targetEntity=DestinationCorrespondence::class, mappedBy="destinationSecondary", orphanRemoval=true)
*/
private $destinationCorrespondences;
/**
* @ORM\OneToOne(targetEntity=DestinationSecondaryComputed::class, mappedBy="destinationSecondary")
*/
private ?DestinationSecondaryComputed $computed = null;
public function __construct()
{
parent::__construct();
$this->itineraryRelations = new ArrayCollection();
}
public function getMainDestination(): ?DestinationMain
{
return $this->mainDestination;
}
public function setMainDestination(?DestinationMain $mainDestination): self
{
$this->mainDestination = $mainDestination;
return $this;
}
/**
* @return Collection<int, ItinerarySecondaryDestination>
*/
public function getItineraryRelations(): Collection
{
return $this->itineraryRelations;
}
public function addItineraryRelation(ItinerarySecondaryDestination $itineraryRelation): self
{
if (!$this->itineraryRelations->contains($itineraryRelation)) {
$this->itineraryRelations[] = $itineraryRelation;
$itineraryRelation->setSecondaryDestination($this);
}
return $this;
}
public function removeItineraryRelation(ItinerarySecondaryDestination $itineraryRelation): self
{
if ($this->itineraryRelations->removeElement($itineraryRelation)) {
// set the owning side to null (unless already changed)
if ($itineraryRelation->getSecondaryDestination() === $this) {
$itineraryRelation->setSecondaryDestination(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->setDestinationSecondary($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->getDestinationSecondary() === $this) {
$destinationCorrespondence->setDestinationSecondary(null);
}
}
return $this;
}
public function getComputed(): ?DestinationSecondaryComputed
{
return $this->computed;
}
public function setComputed(?DestinationSecondaryComputed $computed): DestinationSecondary
{
$this->computed = $computed;
return $this;
}
}