<?php

declare(strict_types=1);

namespace App\Entity\Booking;

use ApiPlatform\Metadata\ApiResource;
use App\Entity\Access\Access;
// use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
use App\Entity\Organization\Organization;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table PersonHoliday, et supprimer l'attribut discr.
 *
 * Périodes de vacances d'un Access
 */
#[ApiResource(operations: [])]
// #[Auditable]
#[ORM\Entity]
class PersonHoliday extends AbstractBooking
{
    #[ORM\ManyToOne(inversedBy: 'holidays')]
    private ?Access $access = null;

    #[ORM\ManyToOne(targetEntity: Organization::class, cascade: [])]
    #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
    protected Organization $organization;

    /** @var Collection<int, PersonHolidayRecur> */
    #[ORM\OneToMany(targetEntity: PersonHolidayRecur::class, mappedBy: 'event', cascade: ['persist', 'remove'])]
    protected Collection $eventRecur;

    public function getAccess(): ?Access
    {
        return $this->access;
    }

    public function setAccess(?Access $access): self
    {
        $this->access = $access;

        return $this;
    }

    public function getOrganization(): Organization
    {
        return $this->organization;
    }

    public function setOrganization(Organization $organization): self
    {
        $this->organization = $organization;

        return $this;
    }

    public function getOrganizer(): Collection
    {
        return $this->organizer;
    }

    public function addOrganizer(Access $organizer): self
    {
        $this->organizer[] = $organizer;

        return $this;
    }

    public function removeOrganizer(Access $organizer): self
    {
        $this->organizer->removeElement($organizer);

        return $this;
    }
}
