src/Entity/FilePerson.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FilePersonRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File as SymfonyFile;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. #[ORM\Entity(repositoryClassFilePersonRepository::class)]
  8. #[Vich\Uploadable]
  9. class FilePerson extends File
  10. {
  11.     #[Vich\UploadableField('person''name''size''mimeType''originalName')]
  12.     protected ?SymfonyFile $file null;
  13.     #[ORM\ManyToOne(targetEntityPerson::class, inversedBy'files')]
  14.     private $owner;
  15.     public function getOwner(): ?Person
  16.     {
  17.         return $this->owner;
  18.     }
  19.     public function setOwner(?Person $owner): self
  20.     {
  21.         $this->owner $owner;
  22.         return $this;
  23.     }
  24.     public function getOwnerId()
  25.     {
  26.         if ($this->getOwner()) {
  27.             return $this->getOwner()->getId();
  28.         }
  29.         return 'anonymous';
  30.     }
  31. }