src/Entity/Document.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DocumentRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10.  * @ORM\Entity(repositoryClass=DocumentRepository::class)
  11.  * @ORM\HasLifecycleCallbacks()
  12.  * @Vich\Uploadable
  13.  */
  14. class Document
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $document;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true)
  28.      * @var string|null
  29.      */
  30.     private $name;
  31.     /**
  32.      * @Vich\UploadableField(mapping="visio_documents", fileNameProperty="document", originalName="name")
  33.      * @Assert\File(
  34.      *     mimeTypes={"image/jpeg", "image/gif", "image/png", "application/pdf"},
  35.      *     maxSize="700Ki",
  36.      *     mimeTypesMessage="document_upload_type"
  37.      * )
  38.      * @var File
  39.      */
  40.     protected $documentFile;
  41.     /**
  42.      * @ORM\Column(type="datetime", nullable=true)
  43.      * @Gedmo\Timestampable(on="update")
  44.      */
  45.     private $updatedAt;
  46.     /**
  47.      * @ORM\Column(type="datetime")
  48.      */
  49.     private $createdAt;
  50.     /**
  51.      * @ORM\ManyToOne(targetEntity=VisioEvent::class, inversedBy="documents")
  52.      */
  53.     private $visioEvent;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="documents")
  56.      */
  57.     private $owner;
  58.     public function __construct()
  59.     {
  60.         $this->createdAt = new \DateTime();
  61.     }
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getDocument(): ?string
  67.     {
  68.         return $this->document;
  69.     }
  70.     public function setDocument(?string $document): self
  71.     {
  72.         $this->document $document;
  73.         return $this;
  74.     }
  75.     public function getUpdatedAt(): ?\DateTimeInterface
  76.     {
  77.         return $this->updatedAt;
  78.     }
  79.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  80.     {
  81.         $this->updatedAt $updatedAt;
  82.         return $this;
  83.     }
  84.     public function getCreatedAt(): ?\DateTimeInterface
  85.     {
  86.         return $this->createdAt;
  87.     }
  88.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  89.     {
  90.         $this->createdAt $createdAt;
  91.         return $this;
  92.     }
  93.     public function getVisioEvent(): ?VisioEvent
  94.     {
  95.         return $this->visioEvent;
  96.     }
  97.     public function setVisioEvent(?VisioEvent $visioEvent): self
  98.     {
  99.         $this->visioEvent $visioEvent;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @param File|null $documentFile
  104.      * @return Document
  105.      */
  106.     public function setDocumentFile(?File $documentFile null): self
  107.     {
  108.         $this->documentFile $documentFile;
  109.         if ($documentFile) {
  110.             // if 'updatedAt' is not defined in your entity, use another property
  111.             $this->updatedAt = new \DateTime('now');
  112.         }
  113.         return $this;
  114.     }
  115.     /**
  116.      * @return File|null
  117.      */
  118.     public function getDocumentFile(): ?File
  119.     {
  120.         return $this->documentFile;
  121.     }
  122.     public function getOwner(): ?User
  123.     {
  124.         return $this->owner;
  125.     }
  126.     public function setOwner(?User $owner): self
  127.     {
  128.         $this->owner $owner;
  129.         return $this;
  130.     }
  131.     /**
  132.      * @param string|null $name
  133.      * @return Document
  134.      */
  135.     public function setName(?string $name): Document
  136.     {
  137.         $this->name $name;
  138.         return $this;
  139.     }
  140.     /**
  141.      * @return string|null
  142.      */
  143.     public function getName(): ?string
  144.     {
  145.         return $this->name;
  146.     }
  147. }