<?php
namespace App\Entity;
use App\Repository\FilePersonRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File as SymfonyFile;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: FilePersonRepository::class)]
#[Vich\Uploadable]
class FilePerson extends File
{
#[Vich\UploadableField('person', 'name', 'size', 'mimeType', 'originalName')]
protected ?SymfonyFile $file = null;
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'files')]
private $owner;
public function getOwner(): ?Person
{
return $this->owner;
}
public function setOwner(?Person $owner): self
{
$this->owner = $owner;
return $this;
}
public function getOwnerId()
{
if ($this->getOwner()) {
return $this->getOwner()->getId();
}
return 'anonymous';
}
}