<?phpnamespace App\Entity;use App\Repository\ImageManagerRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\HttpFoundation\File\File;use Symfony\Component\HttpFoundation\File\UploadedFile;use Vich\UploaderBundle\Mapping\Annotation as Vich;use JMS\Serializer\Annotation as Serializer;/** * @ORM\Entity(repositoryClass=ImageManagerRepository::class) * @Vich\Uploadable * @Serializer\ExclusionPolicy("ALL") */class ImageManager{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * NOTE: This is not a mapped field of entity metadata, just a simple property. * * @Vich\UploadableField(mapping="image_file", fileNameProperty="fileName", size="fileSize") * * @var File|null */ private $file; /** * @ORM\Column(type="string", length=255, nullable=true) * @Serializer\Expose */ private $fileName; /** * @ORM\Column(type="integer", nullable=true) */ private $fileSize; /** * @ORM\Column(type="datetime", nullable=true) */ private $updatedAt; 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|null $file * @throws \Exception */ public function setFile(?File $file = null): void { $this->file = $file; if ($file) { $this->updatedAt = new \DateTime('now'); } } public function getFile(): ?File { return $this->file; } public function getFileName(): ?string { return $this->fileName; } public function setFileName(?string $fileName): self { $this->fileName = $fileName; return $this; } public function getFileSize(): ?int { return $this->fileSize; } public function setFileSize(?int $fileSize): self { $this->fileSize = $fileSize; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(?\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; }}