<?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\SkipperRepository")
* @ORM\Table(name="skippers")
*/
class Skipper
{
/**
* @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\Participation", mappedBy="skipper", cascade={"remove"})
*/
private $participations;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Site\AccessSite", mappedBy="skippers")
*/
private $accessSites;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Media\Document", mappedBy="skippers")
*/
private $documents;
public function __construct()
{
$this->participations = new ArrayCollection();
$this->accessSites = new ArrayCollection();
$this->documents = 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 setUpdatedDate(?\DateTimeInterface $updatedDate): self
{
$this->updatedDate = $updatedDate;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(?int $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection|Participation[]
*/
public function getParticipations(): Collection
{
return $this->participations;
}
public function addParticipation(Participation $participation): self
{
if (!$this->participations->contains($participation)) {
$this->participations[] = $participation;
$participation->setSkipper($this);
}
return $this;
}
public function removeParticipation(Participation $participation): self
{
if ($this->participations->contains($participation)) {
$this->participations->removeElement($participation);
// set the owning side to null (unless already changed)
if ($participation->getSkipper() === $this) {
$participation->setSkipper(null);
}
}
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->addSkipper($this);
}
return $this;
}
public function removeAccessSite(AccessSite $accessSite): self
{
if ($this->accessSites->contains($accessSite)) {
$this->accessSites->removeElement($accessSite);
$accessSite->removeSkipper($this);
}
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->addSkipper($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
$document->removeSkipper($this);
}
return $this;
}
public function __toString(): string
{
return $this->name ? $this->name : '';
}
}