<?php
namespace App\Entity\Federation;
use App\Entity\Media\Document;
use App\Entity\Site\AccessSite;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\Federation\ClassesRepository")
* @ORM\Table(name="classes")
*/
class Classe
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=false)
* @Assert\NotBlank()
*/
private $name;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_date")
* @Gedmo\Timestampable(on="create")
*/
private $createdDate;
/**
* @ORM\Column(type="datetime", nullable=true, name="updated_date")
* @Gedmo\Timestampable(on="update")
*/
private $updatedDate;
/**
* @ORM\Column(type="integer", nullable=true, name="status")
*/
private $status = 1;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Federation\Boat", mappedBy="classe", cascade={"remove"})
*/
private $boats;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Media\Document", mappedBy="classes")
*/
private $documents;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Site\AccessSite", mappedBy="classes")
*/
private $accessSites;
public function __construct()
{
$this->boats = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->accessSites = 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 getCreatedDate(): ?\DateTimeInterface
{
return $this->createdDate;
}
public function getUpdatedDate(): ?\DateTimeInterface
{
return $this->updatedDate;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(?int $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection|Boat[]
*/
public function getBoats(): Collection
{
return $this->boats;
}
public function addBoat(Boat $boat): self
{
if (!$this->boats->contains($boat)) {
$this->boats[] = $boat;
$boat->setClasse($this);
}
return $this;
}
public function removeBoat(Boat $boat): self
{
if ($this->boats->contains($boat)) {
$this->boats->removeElement($boat);
// set the owning side to null (unless already changed)
if ($boat->getClasse() === $this) {
$boat->setClasse(null);
}
}
return $this;
}
/**
* @return Collection|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->addClass($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
$document->removeClass($this);
}
return $this;
}
/**
* @return Collection|AccessSite[]
*/
public function getAccessSites(): Collection
{
return $this->accessSites;
}
public function addAccessSite(AccessSite $accessSite): self
{
if (!$this->accessSites->contains($accessSite)) {
$this->accessSites[] = $accessSite;
$accessSite->addClass($this);
}
return $this;
}
public function removeAccessSite(AccessSite $accessSite): self
{
if ($this->accessSites->contains($accessSite)) {
$this->accessSites->removeElement($accessSite);
$accessSite->removeClass($this);
}
return $this;
}
public function __toString(): string
{
return $this->name ? $this->name : '';
}
}