src/Entity/Document.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DocumentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10.  * @ORM\Entity(repositoryClass=DocumentRepository::class)
  11.  * @Vich\Uploadable
  12.  */
  13. class Document
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(name="idDocument",type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  23.      * 
  24.      * @Vich\UploadableField(mapping="documents", fileNameProperty="name")
  25.      * 
  26.      * @var File|null
  27.      */
  28.     private $nameFile;
  29.     /**
  30.      * @ORM\Column(type="string", nullable=true)
  31.      * 
  32.      * @var string|null
  33.      */
  34.     private $name;
  35.     /**
  36.      * @ORM\Column(type="string", length=1, nullable=true)
  37.      */
  38.     private $target;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private $documentType;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      */
  46.     private $documentMine;
  47.     /**
  48.      * @ORM\Column(type="integer", nullable=true)
  49.      */
  50.     private $uploadedBy;
  51.     /**
  52.      * @ORM\Column(type="datetime", nullable=true)
  53.      *
  54.      * @var \DateTimeInterface|null
  55.      */
  56.     private $updatedAt;
  57.     /**
  58.      * @ORM\Column(type="string", length=255, nullable=true)
  59.      */
  60.     private $category;
  61.     /**
  62.      * @ORM\Column(type="string", length=255, nullable=true)
  63.      */
  64.     private $libelle;
  65.     /**
  66.      * @ORM\OneToMany(targetEntity=Notification::class, mappedBy="documentId")
  67.      */
  68.     private $notifications;
  69.     public function __construct()
  70.     {
  71.         $this->notifications = new ArrayCollection();
  72.     }
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     /**
  78.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  79.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  80.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  81.      * must be able to accept an instance of 'File' as the bundle will inject one here
  82.      * during Doctrine hydration.
  83.      *
  84.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $nameFile
  85.      */
  86.     public function setNameFile(?File $nameFile null): void
  87.     {
  88.         $this->nameFile $nameFile;
  89.         if (null !== $nameFile) {
  90.             // It is required that at least one field changes if you are using doctrine
  91.             // otherwise the event listeners won't be called and the file is lost
  92.             $this->updatedAt = new \DateTimeImmutable();
  93.         }
  94.     }
  95.     public function getNameFile(): ?File
  96.     {
  97.         return $this->nameFile;
  98.     }
  99.     public function getName(): ?string
  100.     {
  101.         return $this->name;
  102.     }
  103.     public function setName(?string $name): self
  104.     {
  105.         $this->name $name;
  106.         return $this;
  107.     }
  108.     public function getTarget(): ?string
  109.     {
  110.         return $this->target;
  111.     }
  112.     public function setTarget(?string $target): self
  113.     {
  114.         $this->target $target;
  115.         return $this;
  116.     }
  117.     public function getDocumentType(): ?string
  118.     {
  119.         return $this->documentType;
  120.     }
  121.     public function setDocumentType(?string $documentType): self
  122.     {
  123.         $this->documentType $documentType;
  124.         return $this;
  125.     }
  126.     public function getDocumentMine(): ?string
  127.     {
  128.         return $this->documentMine;
  129.     }
  130.     public function setDocumentMine(?string $documentMine): self
  131.     {
  132.         $this->documentMine $documentMine;
  133.         return $this;
  134.     }
  135.     public function getUploadedBy(): ?int
  136.     {
  137.         return $this->uploadedBy;
  138.     }
  139.     public function setUploadedBy(?int $uploadedBy): self
  140.     {
  141.         $this->uploadedBy $uploadedBy;
  142.         return $this;
  143.     }
  144.     public function getCategory(): ?string
  145.     {
  146.         return $this->category;
  147.     }
  148.     public function setCategory(?string $category): self
  149.     {
  150.         $this->category $category;
  151.         return $this;
  152.     }
  153.     public function getLibelle(): ?string
  154.     {
  155.         return $this->libelle;
  156.     }
  157.     public function setLibelle(?string $libelle): self
  158.     {
  159.         $this->libelle $libelle;
  160.         return $this;
  161.     }
  162.     /**
  163.      * @return Collection<int, Notification>
  164.      */
  165.     public function getNotifications(): Collection
  166.     {
  167.         return $this->notifications;
  168.     }
  169.     public function addNotification(Notification $notification): self
  170.     {
  171.         if (!$this->notifications->contains($notification)) {
  172.             $this->notifications[] = $notification;
  173.             $notification->setDocument($this);
  174.         }
  175.         return $this;
  176.     }
  177.     public function removeNotification(Notification $notification): self
  178.     {
  179.         if ($this->notifications->removeElement($notification)) {
  180.             // set the owning side to null (unless already changed)
  181.             if ($notification->getDocument() === $this) {
  182.                 $notification->setDocument(null);
  183.             }
  184.         }
  185.         return $this;
  186.     }
  187. }