src/Entity/CommunicationImage.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CommunicationImageRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. /**
  8.  * @Vich\Uploadable
  9.  */
  10. #[ORM\Entity(repositoryClassCommunicationImageRepository::class)]
  11. class CommunicationImage
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private $id;
  17.     #[ORM\Column(type'string'length255nullabletrue)]
  18.     private ?string $imageName null;
  19.     /**
  20.      * @Vich\UploadableField(mapping="communication_mail_file", fileNameProperty="imageName")
  21.      * @var File
  22.      */
  23.     private $imageFile;
  24.     #[ORM\Column(type'datetime')]
  25.     private $updatedAt;
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     public function getImageName(): ?string
  31.     {
  32.         return $this->imageName;
  33.     }
  34.     public function setImageName(?string $imageName): self
  35.     {
  36.         $this->imageName $imageName;
  37.         return $this;
  38.     }
  39.     public function setImageFile(?File $file null)
  40.     {
  41.         $this->imageFile $file;
  42.         // VERY IMPORTANT:
  43.         // It is required that at least one field changes if you are using Doctrine,
  44.         // otherwise the event listeners won't be called and the file is lost
  45.         if ($file) {
  46.             // if 'updatedAt' is not defined in your entity, use another property
  47.             $this->updatedAt = new \DateTime('now');
  48.         }
  49.     }
  50.     public function getImageFile()
  51.     {
  52.         return $this->imageFile;
  53.     }
  54.     public function getUpdatedAt(): ?\DateTimeInterface
  55.     {
  56.         return $this->updatedAt;
  57.     }
  58.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  59.     {
  60.         $this->updatedAt $updatedAt;
  61.         return $this;
  62.     }
  63. }