<?php
declare(strict_types=1);
namespace Croisiland\CommonBundle\Entity\Ship;
use Crea\MediaBundle\Entity\MediaTagOwnerInterface;
use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
use Croisiland\CommonBundle\Annotation\Ship\ShipFormValidator;
use Croisiland\CommonBundle\Entity\Cabin\CabinCategory;
use Croisiland\CommonBundle\Entity\Company\Booklet;
use Croisiland\CommonBundle\Entity\Company\Company;
use Croisiland\CommonBundle\Entity\Cruise\Cruise;
use Croisiland\CommonBundle\Entity\Traits\IsActiveTrait;
use Croisiland\CommonBundle\Entity\Traits\ListOrderTrait;
use Croisiland\CommonBundle\Repository\Ship\ShipRepository;
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=ShipRepository::class)
*
* @ShipFormValidator(groups={"ship_form_validator"})
*/
class Ship implements MediaTagOwnerInterface
{
// TODO: relations
// private $images;
use IsActiveTrait;
use LifecycleUserIdentifierTrait;
use ListOrderTrait;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id;
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $name = null;
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
private ?string $code = null;
/**
* @Gedmo\Slug(handlers={
*
* @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\RelativeSlugHandler", options={
*
* @Gedmo\SlugHandlerOption(name="relationField", value="company"),
* @Gedmo\SlugHandlerOption(name="relationSlugField", value="slug"),
* @Gedmo\SlugHandlerOption(name="separator", value="-"),
* })
* }, fields={"name"})
*
* @ORM\Column(type="string", length=255, nullable=true, unique=true)
*/
private ?string $slug = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $description = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $shortDescription = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $longDescription = null;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private ?int $numberOfMembers = null;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private ?int $numberOfDecks = null;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private ?int $numberOfCabins = null;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private ?int $numberOfPassengers = null;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private ?int $speed = null;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private ?int $width = null;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private ?int $length = null;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $tonnage = null;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private ?int $renovationYear = null;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private ?int $constructionYear = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $additionalInformations = null;
/**
* @ORM\ManyToOne(targetEntity=Company::class, inversedBy="ships")
*
* @ORM\JoinColumn(nullable=false)
*/
private ?Company $company = null;
/**
* @ORM\ManyToOne(targetEntity=Fuel::class, inversedBy="ships")
*/
private ?Fuel $fuel = null;
/**
* @var Collection<int, CabinCategory>
*
* @ORM\OneToMany(targetEntity=CabinCategory::class, mappedBy="ship", orphanRemoval=true)
* @ORM\OrderBy({"listOrder" = "ASC"})
*/
private Collection $cabinCategories;
/**
* @var Collection<int, Cruise>
*
* @ORM\OneToMany(targetEntity=Cruise::class, mappedBy="ship")
* @ORM\OrderBy({"departureDate" = "ASC"})
*/
private Collection $cruises;
/**
* @var Collection<int, Booklet>
*
* @ORM\ManyToMany(targetEntity=Booklet::class, mappedBy="ships")
* @ORM\OrderBy({"listOrder" = "ASC"})
*/
private $booklets;
/**
* @var Collection<int, OnBoardLife>
*
* @ORM\ManyToMany(targetEntity=OnBoardLife::class, mappedBy="ships")
*/
private Collection $onBoardLives;
/**
* @var Collection<int, ShipEnvironmentalAction>
*
* @ORM\ManyToMany(targetEntity=ShipEnvironmentalAction::class, mappedBy="ships")
*/
private Collection $shipEnvironmentalActions;
public function __construct()
{
$this->cabinCategories = new ArrayCollection();
$this->cruises = new ArrayCollection();
$this->booklets = new ArrayCollection();
$this->onBoardLives = new ArrayCollection();
$this->shipEnvironmentalActions = 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 getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
public function getFuel(): ?Fuel
{
return $this->fuel;
}
public function setFuel(?Fuel $fuel): self
{
$this->fuel = $fuel;
return $this;
}
/**
* @return Collection<int, CabinCategory>
*/
public function getCabinCategories(): Collection
{
return $this->cabinCategories;
}
public function addCabinCategory(CabinCategory $cabinCategory): self
{
if (!$this->cabinCategories->contains($cabinCategory)) {
$this->cabinCategories[] = $cabinCategory;
$cabinCategory->setShip($this);
}
return $this;
}
public function removeCabinCategory(CabinCategory $cabinCategory): self
{
if ($this->cabinCategories->removeElement($cabinCategory)) {
// set the owning side to null (unless already changed)
if ($cabinCategory->getShip() === $this) {
$cabinCategory->setShip(null);
}
}
return $this;
}
/**
* @return Collection<int, Cruise>
*/
public function getCruises(): Collection
{
return $this->cruises;
}
public function addCruise(Cruise $cruise): self
{
if (!$this->cruises->contains($cruise)) {
$this->cruises[] = $cruise;
$cruise->setShip($this);
}
return $this;
}
public function removeCruise(Cruise $cruise): self
{
if ($this->cruises->removeElement($cruise)) {
// set the owning side to null (unless already changed)
if ($cruise->getShip() === $this) {
$cruise->setShip(null);
}
}
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
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->addShip($this);
}
return $this;
}
public function removeBooklet(Booklet $booklet): self
{
if ($this->booklets->removeElement($booklet)) {
$booklet->removeShip($this);
}
return $this;
}
/**
* @return Collection<int, OnBoardLife>
*/
public function getOnBoardLives(): Collection
{
return $this->onBoardLives;
}
public function addOnBoardLife(OnBoardLife $onBoardLife): self
{
if (!$this->onBoardLives->contains($onBoardLife)) {
$this->onBoardLives[] = $onBoardLife;
$onBoardLife->addShip($this);
}
return $this;
}
public function removeOnBoardLife(OnBoardLife $onBoardLife): self
{
if ($this->onBoardLives->removeElement($onBoardLife)) {
$onBoardLife->removeShip($this);
}
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getShortDescription(): ?string
{
return $this->shortDescription;
}
public function setShortDescription(?string $shortDescription): self
{
$this->shortDescription = $shortDescription;
return $this;
}
public function getLongDescription(): ?string
{
return $this->longDescription;
}
public function setLongDescription(?string $longDescription): self
{
$this->longDescription = $longDescription;
return $this;
}
public function getNumberOfMembers(): ?int
{
return $this->numberOfMembers;
}
public function setNumberOfMembers(?int $numberOfMembers): self
{
$this->numberOfMembers = $numberOfMembers;
return $this;
}
public function getNumberOfDecks(): ?int
{
return $this->numberOfDecks;
}
public function setNumberOfDecks(?int $numberOfDecks): self
{
$this->numberOfDecks = $numberOfDecks;
return $this;
}
public function getNumberOfCabins(): ?int
{
return $this->numberOfCabins;
}
public function setNumberOfCabins(?int $numberOfCabins): self
{
$this->numberOfCabins = $numberOfCabins;
return $this;
}
public function getNumberOfPassengers(): ?int
{
return $this->numberOfPassengers;
}
public function setNumberOfPassengers(?int $numberOfPassengers): self
{
$this->numberOfPassengers = $numberOfPassengers;
return $this;
}
public function getSpeed(): ?int
{
return $this->speed;
}
public function setSpeed(?int $speed): self
{
$this->speed = $speed;
return $this;
}
public function getWidth(): ?int
{
return $this->width;
}
public function setWidth(?int $width): self
{
$this->width = $width;
return $this;
}
public function getLength(): ?int
{
return $this->length;
}
public function setLength(?int $length): self
{
$this->length = $length;
return $this;
}
public function getTonnage(): ?int
{
return $this->tonnage;
}
public function setTonnage(?int $tonnage): self
{
$this->tonnage = $tonnage;
return $this;
}
public function getRenovationYear(): ?int
{
return $this->renovationYear;
}
public function setRenovationYear(?int $renovationYear): self
{
$this->renovationYear = $renovationYear;
return $this;
}
public function getConstructionYear(): ?int
{
return $this->constructionYear;
}
public function setConstructionYear(?int $constructionYear): self
{
$this->constructionYear = $constructionYear;
return $this;
}
public function getAdditionalInformations(): ?string
{
return $this->additionalInformations;
}
public function setAdditionalInformations(?string $additionalInformations): self
{
$this->additionalInformations = $additionalInformations;
return $this;
}
/**
* @return Collection<int, ShipEnvironmentalAction>
*/
public function getShipEnvironmentalActions(): Collection
{
return $this->shipEnvironmentalActions;
}
public function addShipEnvironmentalAction(ShipEnvironmentalAction $shipEnvironmentalAction): self
{
if (!$this->shipEnvironmentalActions->contains($shipEnvironmentalAction)) {
$this->shipEnvironmentalActions[] = $shipEnvironmentalAction;
$shipEnvironmentalAction->addShip($this);
}
return $this;
}
public function removeShipEnvironmentalAction(ShipEnvironmentalAction $shipEnvironmentalAction): self
{
if ($this->shipEnvironmentalActions->removeElement($shipEnvironmentalAction)) {
$shipEnvironmentalAction->removeShip($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);
}
}