<?php
namespace App\Entity\Federation;
use App\Entity\Site\AccessSite;
use App\Entity\Site\Site;
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;
use App\Entity\Media\Document;
/**
* @ORM\Entity(repositoryClass="App\Repository\Federation\TeamRepository")
* @ORM\Table(name="teams")
*/
class Team
{
/**
* @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\Site\Site", mappedBy="team")
*/
private $sites;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Site\AccessSite", mappedBy="teams")
*/
private $accessSites;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Federation\Participation", mappedBy="teams", cascade={"remove"})
*/
private $participations;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Media\Document", mappedBy="teams")
*/
private $documents;
public function __construct()
{
$this->sites = new ArrayCollection();
$this->accessSites = new ArrayCollection();
$this->participations = 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 getStatus(): ?int
{
return $this->status;
}
public function setStatus(?int $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection|Site[]
*/
public function getSites(): Collection
{
return $this->sites;
}
public function addSite(Site $site): self
{
if (!$this->sites->contains($site)) {
$this->sites[] = $site;
$site->setTeam($this);
}
return $this;
}
public function removeSite(Site $site): self
{
if ($this->sites->contains($site)) {
$this->sites->removeElement($site);
// set the owning side to null (unless already changed)
if ($site->getTeam() === $this) {
$site->setTeam(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->addTeam($this);
}
return $this;
}
public function removeAccessSite(AccessSite $accessSite): self
{
if ($this->accessSites->contains($accessSite)) {
$this->accessSites->removeElement($accessSite);
$accessSite->removeTeam($this);
}
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->addTeam($this);
}
return $this;
}
public function removeParticipation(Participation $participation): self
{
if ($this->participations->contains($participation)) {
$this->participations->removeElement($participation);
$participation->removeTeam($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->addTeam($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
$document->removeTeam($this);
}
return $this;
}
public function __toString(): string
{
return $this->name ? $this->name : '';
}
}