src/Entity/Document.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\TimeStampable;
  4. use App\Repository\DocumentRepository;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClass: DocumentRepository::class)]
  12. #[Vich\Uploadable]
  13. #[ORM\HasLifecycleCallbacks]
  14. class Document
  15. {
  16.     use TimeStampable; 
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column]
  20.     #[Groups(['documentProjet:read'])]
  21.     private ?int $id = null;
  22.     #[ORM\Column(length: 255, nullable:true)]
  23.     #[Groups(['documentProjet:read'])]
  24.     private ?string $titre = null;
  25.     #[ORM\Column(length: 255)]
  26.     #[Groups(['documentProjet:read'])]
  27.     private ?string $file = null;
  28.     #[ORM\ManyToOne(inversedBy: 'documents')]
  29.     private ?Task $tache = null;
  30.  
  31.     #[Vich\UploadableField(mapping: 'document_projet', fileNameProperty: 'file')]
  32.     #[Assert\NotBlank(message:"Veuillez remplir ce champ")]
  33.     private ?File $imageFile = null;
  34.     #[ORM\Column(nullable: true)]
  35.     private ?\DateTimeImmutable $updatedAtFile = null;
  36.     #[ORM\ManyToOne(inversedBy: 'documents')]
  37.     private ?Projet $projet = null;
  38.     #[ORM\Column(type: Types::TEXT, nullable: true)]
  39.     #[Groups(['documentProjet:read'])]
  40.     private ?string $description = null;
  41.     #[ORM\ManyToOne(inversedBy: 'documents')]
  42.     #[Groups(['documentProjet:read'])]
  43.     #[Assert\NotBlank(message:"Veuillez remplir ce champ")]
  44.     private ?DocumentType $typeDocument = null;
  45.     #[Groups(['documentProjet:read'])]
  46.     #[ORM\ManyToOne(inversedBy: 'documents')]
  47.     private ?User $author = null;
  48.     #[ORM\ManyToOne(inversedBy: 'documents')]
  49.     private ?RateOfProgress $rateOfProgress = null;
  50.     public function __construct() 
  51.     {
  52.         $this->createdAt = new \DateTimeImmutable();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getTitre(): ?string
  59.     {
  60.         return $this->titre;
  61.     }
  62.     public function setTitre(?string $titre): static
  63.     {
  64.         $this->titre = $titre;
  65.         return $this;
  66.     }
  67.     public function getFile(): ?string
  68.     {
  69.         return $this->file;
  70.     }
  71.     public function setFile(?string $file): static
  72.     {
  73.         $this->file = $file;
  74.         return $this;
  75.     }
  76.     public function getTache(): ?Task
  77.     {
  78.         return $this->tache;
  79.     }
  80.     public function setTache(?Task $tache): static
  81.     {
  82.         $this->tache = $tache;
  83.         return $this;
  84.     }
  85.     /**
  86.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  87.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  88.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  89.      * must be able to accept an instance of 'File' as the bundle will inject one here
  90.      * during Doctrine hydration.
  91.      *
  92.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  93.      */
  94.     public function setImageFile(?File $imageFile = null): void
  95.     {
  96.         $this->imageFile = $imageFile;
  97.         if (null !== $imageFile) {
  98.             // It is required that at least one field changes if you are using doctrine
  99.             // otherwise the event listeners won't be called and the file is lost
  100.             $this->updatedAtFile = new \DateTimeImmutable();
  101.         }
  102.     }
  103.     public function getImageFile(): ?File
  104.     {
  105.         return $this->imageFile;
  106.     }
  107.     public function getProjet(): ?Projet
  108.     {
  109.         return $this->projet;
  110.     }
  111.     public function setProjet(?Projet $projet): static
  112.     {
  113.         $this->projet = $projet;
  114.         return $this;
  115.     }
  116.     public function getDescription(): ?string
  117.     {
  118.         return $this->description;
  119.     }
  120.     public function setDescription(?string $description): static
  121.     {
  122.         $this->description = $description;
  123.         return $this;
  124.     }
  125.     public function getTypeDocument(): ?DocumentType
  126.     {
  127.         return $this->typeDocument;
  128.     }
  129.     public function setTypeDocument(?DocumentType $typeDocument): static
  130.     {
  131.         $this->typeDocument = $typeDocument;
  132.         return $this;
  133.     }
  134.     public function getAuthor(): ?User
  135.     {
  136.         return $this->author;
  137.     }
  138.     public function setAuthor(?User $author): static
  139.     {
  140.         $this->author = $author;
  141.         return $this;
  142.     }
  143.     public function getRateOfProgress(): ?RateOfProgress
  144.     {
  145.         return $this->rateOfProgress;
  146.     }
  147.     public function setRateOfProgress(?RateOfProgress $rateOfProgress): static
  148.     {
  149.         $this->rateOfProgress = $rateOfProgress;
  150.         return $this;
  151.     }
  152. }