<?php
namespace App\Entity\Media;
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\Federation\Race;
use Gedmo\Translatable\Translatable;
/**
* @ORM\Entity(repositoryClass="App\Repository\Media\DocumentTypeRepository")
* @ORM\Table(name="documents_types")
* @Gedmo\TranslationEntity(class="App\Entity\Translation\DocumentTypeTranslation")
*/
class DocumentType
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank()
* @Gedmo\Translatable
*/
#[Gedmo\Translatable]
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $icon;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank()
*/
private $directoryName;
/**
* @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=false, name="status")
*/
private $status = 1;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Media\Document", mappedBy="documentType")
*/
private $documents;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Media\Category", mappedBy="documentType")
*/
private $categories;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Federation\Race", inversedBy="documentTypes")
* @ORM\JoinTable(
* name="races_document_types",
* joinColumns={@ORM\JoinColumn(name="document_type_id", referencedColumnName="id", nullable=false)},
* inverseJoinColumns={@ORM\JoinColumn(name="race_id", referencedColumnName="id", nullable=false)}
* )
*/
private $races;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Site\AccessSite", mappedBy="documentTypes")
*/
private $accessSites;
/**
* @Gedmo\Locale
*/
private $locale;
public function __construct()
{
$this->documents = new ArrayCollection();
$this->categories = new ArrayCollection();
$this->races = 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 getIcon(): ?string
{
return $this->icon;
}
public function setIcon(?string $icon): self
{
$this->icon = $icon;
return $this;
}
public function getDirectoryName(): ?string
{
return $this->directoryName;
}
public function setDirectoryName(?string $directoryName): self
{
$this->directoryName = $directoryName;
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|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setDocumentType($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
// set the owning side to null (unless already changed)
if ($document->getDocumentType() === $this) {
$document->setDocumentType(null);
}
}
return $this;
}
/**
* @return Collection|Category[]
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(Category $category): self
{
if (!$this->categories->contains($category)) {
$this->categories[] = $category;
$category->setDocumentType($this);
}
return $this;
}
public function removeCategory(Category $category): self
{
if ($this->categories->contains($category)) {
$this->categories->removeElement($category);
// set the owning side to null (unless already changed)
if ($category->getDocumentType() === $this) {
$category->setDocumentType(null);
}
}
return $this;
}
/**
* @return Collection|Race[]
*/
public function getRaces(): Collection
{
return $this->races;
}
public function addRace(Race $race): self
{
if (!$this->races->contains($race)) {
$this->races[] = $race;
}
return $this;
}
public function removeRace(Race $race): self
{
if ($this->races->contains($race)) {
$this->races->removeElement($race);
}
return $this;
}
/**
* @return Collection|DocumentType[]
*/
public function getAccessSites(): Collection
{
return $this->accessSites;
}
public function addAccessSite(DocumentType $accessSite): self
{
if (!$this->accessSites->contains($accessSite)) {
$this->accessSites[] = $accessSite;
$accessSite->addAccessSite($this);
}
return $this;
}
public function removeAccessSite(DocumentType $accessSite): self
{
if ($this->accessSites->contains($accessSite)) {
$this->accessSites->removeElement($accessSite);
$accessSite->removeAccessSite($this);
}
return $this;
}
public function setTranslatableLocale($locale)
{
$this->locale = $locale;
}
}