<?php
namespace App\Entity;
use App\Repository\DocumentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=DocumentRepository::class)
* @Vich\Uploadable
*/
class Document
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(name="idDocument",type="integer")
*/
private $id;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="documents", fileNameProperty="name")
*
* @var File|null
*/
private $nameFile;
/**
* @ORM\Column(type="string", nullable=true)
*
* @var string|null
*/
private $name;
/**
* @ORM\Column(type="string", length=1, nullable=true)
*/
private $target;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $documentType;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $documentMine;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $uploadedBy;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @var \DateTimeInterface|null
*/
private $updatedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $category;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $libelle;
/**
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="documentId")
*/
private $notifications;
public function __construct()
{
$this->notifications = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $nameFile
*/
public function setNameFile(?File $nameFile = null): void
{
$this->nameFile = $nameFile;
if (null !== $nameFile) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getNameFile(): ?File
{
return $this->nameFile;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getTarget(): ?string
{
return $this->target;
}
public function setTarget(?string $target): self
{
$this->target = $target;
return $this;
}
public function getDocumentType(): ?string
{
return $this->documentType;
}
public function setDocumentType(?string $documentType): self
{
$this->documentType = $documentType;
return $this;
}
public function getDocumentMine(): ?string
{
return $this->documentMine;
}
public function setDocumentMine(?string $documentMine): self
{
$this->documentMine = $documentMine;
return $this;
}
public function getUploadedBy(): ?int
{
return $this->uploadedBy;
}
public function setUploadedBy(?int $uploadedBy): self
{
$this->uploadedBy = $uploadedBy;
return $this;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(?string $category): self
{
$this->category = $category;
return $this;
}
public function getLibelle(): ?string
{
return $this->libelle;
}
public function setLibelle(?string $libelle): self
{
$this->libelle = $libelle;
return $this;
}
/**
* @return Collection<int, Notification>
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setDocument($this);
}
return $this;
}
public function removeNotification(Notification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getDocument() === $this) {
$notification->setDocument(null);
}
}
return $this;
}
}