<?php
declare(strict_types=1);
namespace Croisiland\CommonBundle\Entity\Itinerary;
use Crea\MediaBundle\Entity\MediaTagOwnerInterface;
use Crea\ParameterBundle\Entity\Parameter;
use Crea\ToolsBundle\Entity\Geographic\Country;
use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
use Croisiland\CommonBundle\Annotation\Itinerary\ItineraryStopoverFormValidator;
use Croisiland\CommonBundle\Entity\Correspondence\StopoverCorrespondence;
use Croisiland\CommonBundle\Entity\Traits\ListOrderTrait;
use Croisiland\CommonBundle\Repository\Itinerary\StopoverRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ItineraryStopoverFormValidator(groups="itinerary_stopover_form_validator")
*
* @UniqueEntity(
* fields={"slug"},
* errorPath="slug",
* message="stopover.slug.unique_constraint",
* ignoreNull=true
* )
*
* @ORM\Entity(repositoryClass=StopoverRepository::class)
*/
class Stopover implements MediaTagOwnerInterface
{
use ListOrderTrait;
use LifecycleUserIdentifierTrait;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $name = null;
/**
* @Gedmo\Slug(fields={"name"}, updatable=false)
*
* @ORM\Column(type="string", length=255, nullable=true, unique=true)
*/
private ?string $slug = null;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" = false})
*/
private bool $favorite = false;
/**
* @ORM\ManyToOne(targetEntity=Country::class)
*/
private ?Country $country = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $description = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $whatToDo = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $accessGuide = null;
/**
* @ORM\Column(type="float", nullable=true)
*/
private ?float $latitude = null;
/**
* @ORM\Column(type="float", nullable=true)
*/
private ?float $longitude = null;
/**
* @ORM\ManyToOne(targetEntity=Parameter::class)
*
* @ORM\JoinColumn(nullable=false)
*/
private ?Parameter $creationOrigin = null;
/**
* @var Collection<int, StopoverCorrespondence>
*
* @ORM\OneToMany(targetEntity=StopoverCorrespondence::class, mappedBy="stopover", orphanRemoval=true, cascade={"remove"})
*/
private $stopoverCorrespondences;
/**
* @var Collection<int, ItinerarySegment>
*
* @ORM\OneToMany(targetEntity=ItinerarySegment::class, mappedBy="stopover", orphanRemoval=true, cascade={"remove"})
*/
private $itinerarySegments;
/**
* @ORM\OneToOne(targetEntity=StopoverComputed::class, mappedBy="stopover")
*/
private ?StopoverComputed $computed = null;
public function __construct()
{
$this->stopoverCorrespondences = new ArrayCollection();
$this->itinerarySegments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function isFavorite(): bool
{
return $this->favorite;
}
public function setFavorite(bool $favorite): Stopover
{
$this->favorite = $favorite;
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getAccessGuide(): ?string
{
return $this->accessGuide;
}
public function setAccessGuide(?string $accessGuide): Stopover
{
$this->accessGuide = $accessGuide;
return $this;
}
public function getWhatToDo(): ?string
{
return $this->whatToDo;
}
public function setWhatToDo(?string $whatToDo): Stopover
{
$this->whatToDo = $whatToDo;
return $this;
}
public function getLatitude(): ?float
{
return $this->latitude;
}
public function setLatitude(?float $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function getLongitude(): ?float
{
return $this->longitude;
}
public function setLongitude(?float $longitude): self
{
$this->longitude = $longitude;
return $this;
}
public function getCreationOrigin(): ?Parameter
{
return $this->creationOrigin;
}
public function setCreationOrigin(?Parameter $creationOrigin): self
{
$this->creationOrigin = $creationOrigin;
return $this;
}
/**
* @return Collection<int, StopoverCorrespondence>
*/
public function getStopoverCorrespondences(): Collection
{
return $this->stopoverCorrespondences;
}
public function addStopoverCorrespondence(StopoverCorrespondence $stopoverCorrespondence): self
{
if (!$this->stopoverCorrespondences->contains($stopoverCorrespondence)) {
$this->stopoverCorrespondences[] = $stopoverCorrespondence;
$stopoverCorrespondence->setStopover($this);
}
return $this;
}
public function removeStopoverCorrespondence(StopoverCorrespondence $stopoverCorrespondence): self
{
if ($this->stopoverCorrespondences->removeElement($stopoverCorrespondence)) {
// set the owning side to null (unless already changed)
if ($stopoverCorrespondence->getStopover() === $this) {
$stopoverCorrespondence->setStopover(null);
}
}
return $this;
}
/**
* @return Collection<int, ItinerarySegment>
*/
public function getItinerarySegments(): Collection
{
return $this->itinerarySegments;
}
public function addItinerarySegment(ItinerarySegment $itinerarySegment): self
{
if (!$this->itinerarySegments->contains($itinerarySegment)) {
$this->itinerarySegments[] = $itinerarySegment;
$itinerarySegment->setStopover($this);
}
return $this;
}
public function removeItinerarySegment(ItinerarySegment $itinerarySegment): self
{
if ($this->itinerarySegments->removeElement($itinerarySegment)) {
// set the owning side to null (unless already changed)
if ($itinerarySegment->getStopover() === $this) {
$itinerarySegment->setStopover(null);
}
}
return $this;
}
public function getComputed(): ?StopoverComputed
{
return $this->computed;
}
public function setComputed(?StopoverComputed $computed): Stopover
{
$this->computed = $computed;
return $this;
}
/**
* Method liée au Média Bundle
*/
public function getMediaTagOwnerLabel(): ?string
{
return $this->getName();
}
/**
* Method liée au Média Bundle
* @return class-string
*/
public function getFqcn(): string
{
return ClassUtils::getClass($this);
}
}