<?php
declare(strict_types=1);

namespace App\Entity\AccessWish;

use App\Entity\Core\File;
use App\Entity\Person\Person;
//use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;

/**
 * Classe ... qui ...
 */
//#[Auditable]
#[ORM\Entity]
class DocumentWish
{
    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    #[ORM\ManyToOne(inversedBy: 'documentWishes')]
    #[ORM\JoinColumn(referencedColumnName: 'id' ,nullable: true, onDelete: 'SET NULL')]
    private AccessWish $accessWish;

    #[ORM\ManyToOne(inversedBy: 'documentWishes')]
    #[ORM\JoinColumn(referencedColumnName: 'id' ,nullable: true, onDelete: 'SET NULL')]
    private Person $personOwner;

    #[ORM\OneToMany(mappedBy: 'documentWish', targetEntity: File::class, orphanRemoval: true)]
    private Collection $files;

    public function __construct()
    {
        $this->files = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getAccessWish(): ?AccessWish
    {
        return $this->accessWish;
    }

    public function setAccessWish(?AccessWish $accessWish): self
    {
        $this->accessWish = $accessWish;

        return $this;
    }

    public function getPersonOwner(): ?Person
    {
        return $this->personOwner;
    }

    public function setPersonOwner(?Person $personOwner): self
    {
        $this->personOwner = $personOwner;

        return $this;
    }

    /**
     * @return Collection<int, File>
     */
    public function getFiles(): Collection
    {
        return $this->files;
    }

    public function addFile(File $file): self
    {
        if (!$this->files->contains($file)) {
            $this->files[] = $file;
            $file->setDocumentWish($this);
        }

        return $this;
    }

    public function removeFile(File $file): self
    {
        if ($this->files->removeElement($file)) {
            // set the owning side to null (unless already changed)
            if ($file->getDocumentWish() === $this) {
                $file->setDocumentWish(null);
            }
        }

        return $this;
    }
}