<?php
declare(strict_types=1);
namespace Croisiland\CommonBundle\Entity\Company;
use Crea\MediaBundle\Entity\MediaTagOwnerInterface;
use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
use Croisiland\CommonBundle\Annotation\Company\CompanyFormValidator;
use Croisiland\CommonBundle\Entity\Cabin\CabinSubType;
use Croisiland\CommonBundle\Entity\Correspondence\DestinationCorrespondence;
use Croisiland\CommonBundle\Entity\Itinerary\Itinerary;
use Croisiland\CommonBundle\Entity\Offer\Offer;
use Croisiland\CommonBundle\Entity\Partner\PartnerCompanyDiscount;
use Croisiland\CommonBundle\Entity\Price\PriceCostType;
use Croisiland\CommonBundle\Entity\Price\ServiceChargeType;
use Croisiland\CommonBundle\Entity\Price\PriceSupplementType;
use Croisiland\CommonBundle\Entity\Ship\Ship;
use Croisiland\CommonBundle\Entity\Traits\IncludedExcludedTrait;
use Croisiland\CommonBundle\Entity\Traits\IsActiveTrait;
use Croisiland\CommonBundle\Entity\Traits\ListOrderTrait;
use Croisiland\CommonBundle\Repository\Company\CompanyRepository;
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;
/**
* @ORM\Entity(repositoryClass=CompanyRepository::class)
*
* @CompanyFormValidator(groups={"company_form_validator"})
*/
class Company implements MediaTagOwnerInterface
{
use ListOrderTrait;
use IsActiveTrait;
use LifecycleUserIdentifierTrait;
use IncludedExcludedTrait;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $name = null;
/**
* @ORM\Column(type="text", name="`lead`", nullable=true)
*
* Note: The column name "lead" is a reserved keyword in MySQL/Percona (used by the LEAD() window function).
* We use backticks in the name to avoid SQL syntax errors during schema generation and migrations.
*/
private ?string $lead = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $description = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $listDescription = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $midDescription = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $usefulInformations = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $additionalInformations = null;
/**
* @ORM\Column(type="string", length=64, nullable=true, unique=true)
*/
private ?string $code = null;
/**
* @var Collection<int, Advantage>
*
* @ORM\OneToMany(targetEntity=Advantage::class, mappedBy="company", orphanRemoval=false)
*
* @ORM\OrderBy(value={"listOrder"="ASC"})
*/
private Collection $advantages;
/**
* @var Collection<int, Atmosphere>
*
* @ORM\OneToMany(targetEntity=Atmosphere::class, mappedBy="company", orphanRemoval=false)
* @ORM\OrderBy({"listOrder" = "ASC"})
*/
private Collection $atmospheres;
/**
* @var Collection<int, Booklet>
*
* @ORM\OneToMany(targetEntity=Booklet::class, mappedBy="company", orphanRemoval=false)
*/
private Collection $booklets;
/**
* @var Collection<int, CompanyTermsOfSelling>
*
* @ORM\OneToMany(targetEntity=CompanyTermsOfSelling::class, mappedBy="company", orphanRemoval=false)
*/
private Collection $companyTermsOfSellings;
/**
* @var Collection<int, Ship>
*
* @ORM\OneToMany(targetEntity=Ship::class, mappedBy="company", orphanRemoval=false)
* @ORM\OrderBy({"listOrder" = "ASC"})
*/
private Collection $ships;
/**
* @var Collection<int, Itinerary>
*
* @ORM\OneToMany(targetEntity=Itinerary::class, mappedBy="originCompany", orphanRemoval=false)
*/
private Collection $originatedItineraries;
/**
* @var Collection<int, DestinationCorrespondence>
*
* @ORM\OneToMany(targetEntity=DestinationCorrespondence::class, mappedBy="originCompany", orphanRemoval=false)
*/
private Collection $originatedCorrespondencesDestinations;
/**
* @Gedmo\Slug(handlers={
*
* @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\InversedRelativeSlugHandler", options={
*
* @Gedmo\SlugHandlerOption(name="relationClass", value="Croisiland\CommonBundle\Entity\Ship\Ship"),
* @Gedmo\SlugHandlerOption(name="mappedBy", value="company"),
* @Gedmo\SlugHandlerOption(name="inverseSlugField", value="slug")
* })
* }, fields={"name"}, updatable=false)
*
* @ORM\Column(type="string", length=255, nullable=true, unique=true)
*/
private ?string $slug = null;
/**
* @var Collection<int, PartnerCompanyDiscount>
*
* @ORM\OneToMany(targetEntity=PartnerCompanyDiscount::class, mappedBy="company", orphanRemoval=false)
*/
private Collection $partnerCompanyDiscounts;
/**
* @var Collection<int, CabinSubType>
*
* @ORM\OneToMany(targetEntity=CabinSubType::class, mappedBy="company", orphanRemoval=false)
*/
private Collection $cabinSubTypes;
/**
* @var Collection<int, PriceCostType>
*
* @ORM\OneToMany(targetEntity=PriceCostType::class, mappedBy="originCompany")
*/
private Collection $priceCostTypes;
/**
* @var Collection<int, ServiceChargeType>
*
* @ORM\OneToMany(targetEntity=ServiceChargeType::class, mappedBy="originCompany")
*/
private Collection $serviceChargeTypes;
/**
* @var Collection<int, PriceSupplementType>
*
* @ORM\OneToMany(targetEntity=PriceSupplementType::class, mappedBy="originCompany")
*/
private Collection $priceSupplementTypes;
/**
* @var Collection<int, Offer>
*
* @ORM\ManyToMany(targetEntity=Offer::class, mappedBy="companies")
*/
private Collection $offers;
public function __construct()
{
$this->advantages = new ArrayCollection();
$this->atmospheres = new ArrayCollection();
$this->booklets = new ArrayCollection();
$this->companyTermsOfSellings = new ArrayCollection();
$this->ships = new ArrayCollection();
$this->partnerCompanyDiscounts = new ArrayCollection();
$this->cabinSubTypes = new ArrayCollection();
$this->priceCostTypes = new ArrayCollection();
$this->serviceChargeTypes = new ArrayCollection();
$this->priceSupplementTypes = new ArrayCollection();
$this->offers = 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 getLead(): ?string
{
return $this->lead;
}
public function setLead(?string $lead): self
{
$this->lead = $lead;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getListDescription(): ?string
{
return $this->listDescription;
}
public function setListDescription(?string $listDescription): self
{
$this->listDescription = $listDescription;
return $this;
}
public function getMidDescription(): ?string
{
return $this->midDescription;
}
public function setMidDescription(?string $midDescription): self
{
$this->midDescription = $midDescription;
return $this;
}
public function getUsefulInformations(): ?string
{
return $this->usefulInformations;
}
public function setUsefulInformations(?string $usefulInformations): self
{
$this->usefulInformations = $usefulInformations;
return $this;
}
public function getAdditionalInformations(): ?string
{
return $this->additionalInformations;
}
public function setAdditionalInformations(?string $additionalInformations): self
{
$this->additionalInformations = $additionalInformations;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
/**
* @return Collection<int, Advantage>
*/
public function getAdvantages(): Collection
{
return $this->advantages;
}
public function addAdvantage(Advantage $advantage): self
{
if (!$this->advantages->contains($advantage)) {
$this->advantages[] = $advantage;
$advantage->setCompany($this);
}
return $this;
}
public function removeAdvantage(Advantage $advantage): self
{
if ($this->advantages->removeElement($advantage)) {
// set the owning side to null (unless already changed)
if ($advantage->getCompany() === $this) {
$advantage->setCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, Atmosphere>
*/
public function getAtmospheres(): Collection
{
return $this->atmospheres;
}
public function addAtmosphere(Atmosphere $atmosphere): self
{
if (!$this->atmospheres->contains($atmosphere)) {
$this->atmospheres[] = $atmosphere;
$atmosphere->setCompany($this);
}
return $this;
}
public function removeAtmosphere(Atmosphere $atmosphere): self
{
if ($this->atmospheres->removeElement($atmosphere)) {
// set the owning side to null (unless already changed)
if ($atmosphere->getCompany() === $this) {
$atmosphere->setCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, Booklet>
*/
public function getBooklets(): Collection
{
return $this->booklets;
}
public function addBooklet(Booklet $booklet): self
{
if (!$this->booklets->contains($booklet)) {
$this->booklets[] = $booklet;
$booklet->setCompany($this);
}
return $this;
}
public function removeBooklet(Booklet $booklet): self
{
if ($this->booklets->removeElement($booklet)) {
// set the owning side to null (unless already changed)
if ($booklet->getCompany() === $this) {
$booklet->setCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, CompanyTermsOfSelling>
*/
public function getCompanyTermsOfSellings(): Collection
{
return $this->companyTermsOfSellings;
}
public function addCompanyTermsOfSelling(CompanyTermsOfSelling $companyTermsOfSelling): self
{
if (!$this->companyTermsOfSellings->contains($companyTermsOfSelling)) {
$this->companyTermsOfSellings[] = $companyTermsOfSelling;
$companyTermsOfSelling->setCompany($this);
}
return $this;
}
public function removeCompanyTermsOfSelling(CompanyTermsOfSelling $companyTermsOfSelling): self
{
if ($this->companyTermsOfSellings->removeElement($companyTermsOfSelling)) {
// set the owning side to null (unless already changed)
if ($companyTermsOfSelling->getCompany() === $this) {
$companyTermsOfSelling->setCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, Ship>
*/
public function getShips(): Collection
{
return $this->ships;
}
public function addShip(Ship $ship): self
{
if (!$this->ships->contains($ship)) {
$this->ships[] = $ship;
$ship->setCompany($this);
}
return $this;
}
public function removeShip(Ship $ship): self
{
if ($this->ships->removeElement($ship)) {
// set the owning side to null (unless already changed)
if ($ship->getCompany() === $this) {
$ship->setCompany(null);
}
}
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, PartnerCompanyDiscount>
*/
public function getPartnerCompanyDiscounts(): Collection
{
return $this->partnerCompanyDiscounts;
}
public function addPartnerCompanyDiscount(PartnerCompanyDiscount $partnerCompanyDiscount): self
{
if (!$this->partnerCompanyDiscounts->contains($partnerCompanyDiscount)) {
$this->partnerCompanyDiscounts[] = $partnerCompanyDiscount;
$partnerCompanyDiscount->setCompany($this);
}
return $this;
}
public function removePartnerCompanyDiscount(PartnerCompanyDiscount $partnerCompanyDiscount): self
{
if ($this->partnerCompanyDiscounts->removeElement($partnerCompanyDiscount)) {
// set the owning side to null (unless already changed)
if ($partnerCompanyDiscount->getCompany() === $this) {
$partnerCompanyDiscount->setCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, Itinerary>
*/
public function getOriginatedItineraries(): Collection
{
return $this->originatedItineraries;
}
public function addOriginatedItinerary(Itinerary $originatedItinerary): self
{
if (!$this->originatedItineraries->contains($originatedItinerary)) {
$this->originatedItineraries[] = $originatedItinerary;
$originatedItinerary->setOriginCompany($this);
}
return $this;
}
public function removeOriginatedItinerary(Itinerary $originatedItinerary): self
{
if ($this->originatedItineraries->removeElement($originatedItinerary)) {
// set the owning side to null (unless already changed)
if ($originatedItinerary->getOriginCompany() === $this) {
$originatedItinerary->setOriginCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, DestinationCorrespondence>
*/
public function getOriginatedCorrespondencesDestinations(): Collection
{
return $this->originatedCorrespondencesDestinations;
}
public function addOriginatedCorrespondencesDestinations(DestinationCorrespondence $destinationCorrespondence): self
{
if (!$this->originatedCorrespondencesDestinations->contains($destinationCorrespondence)) {
$this->originatedCorrespondencesDestinations[] = $destinationCorrespondence;
$destinationCorrespondence->setOriginCompany($this);
}
return $this;
}
public function removeOriginatedCorrespondencesDestinations(DestinationCorrespondence $destinationCorrespondence): self
{
if ($this->originatedCorrespondencesDestinations->removeElement($destinationCorrespondence)) {
// set the owning side to null (unless already changed)
if ($destinationCorrespondence->getOriginCompany() === $this) {
$destinationCorrespondence->setOriginCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, CabinSubType>
*/
public function getCabinSubTypes(): Collection
{
return $this->cabinSubTypes;
}
public function addCabinSubType(CabinSubType $cabinSubType): self
{
if (!$this->cabinSubTypes->contains($cabinSubType)) {
$this->cabinSubTypes[] = $cabinSubType;
$cabinSubType->setCompany($this);
}
return $this;
}
public function removeCabinSubType(CabinSubType $cabinSubType): self
{
if ($this->cabinSubTypes->removeElement($cabinSubType)) {
// set the owning side to null (unless already changed)
if ($cabinSubType->getCompany() === $this) {
$cabinSubType->setCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, PriceCostType>
*/
public function getPriceCostTypes(): Collection
{
return $this->priceCostTypes;
}
public function addPriceCostType(PriceCostType $priceCostType): self
{
if (!$this->priceCostTypes->contains($priceCostType)) {
$this->priceCostTypes[] = $priceCostType;
$priceCostType->setOriginCompany($this);
}
return $this;
}
public function removePriceCostType(PriceCostType $priceCostType): self
{
if ($this->priceCostTypes->removeElement($priceCostType)) {
// set the owning side to null (unless already changed)
if ($priceCostType->getOriginCompany() === $this) {
$priceCostType->setOriginCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, ServiceChargeType>
*/
public function getServiceChargeTypes(): Collection
{
return $this->serviceChargeTypes;
}
public function addServiceChargeType(ServiceChargeType $serviceChargeType): self
{
if (!$this->serviceChargeTypes->contains($serviceChargeType)) {
$this->serviceChargeTypes[] = $serviceChargeType;
$serviceChargeType->setOriginCompany($this);
}
return $this;
}
public function removeServiceChargeType(ServiceChargeType $serviceChargeType): self
{
if ($this->serviceChargeTypes->removeElement($serviceChargeType)) {
// set the owning side to null (unless already changed)
if ($serviceChargeType->getOriginCompany() === $this) {
$serviceChargeType->setOriginCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, PriceSupplementType>
*/
public function getPriceSupplementTypes(): Collection
{
return $this->priceSupplementTypes;
}
public function addPriceSupplementType(PriceSupplementType $priceSupplementType): self
{
if (!$this->priceSupplementTypes->contains($priceSupplementType)) {
$this->priceSupplementTypes[] = $priceSupplementType;
$priceSupplementType->setOriginCompany($this);
}
return $this;
}
public function removePriceSupplementType(PriceSupplementType $priceSupplementType): self
{
if ($this->priceSupplementTypes->removeElement($priceSupplementType)) {
// set the owning side to null (unless already changed)
if ($priceSupplementType->getOriginCompany() === $this) {
$priceSupplementType->setOriginCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, Offer>
*/
public function getOffers(): Collection
{
return $this->offers;
}
public function addOffer(Offer $offer): self
{
if (!$this->offers->contains($offer)) {
$this->offers[] = $offer;
$offer->addCompany($this);
}
return $this;
}
public function removeOffer(Offer $offer): self
{
if ($this->offers->removeElement($offer)) {
$offer->removeCompany($this);
}
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);
}
}