<?php

declare(strict_types=1);

namespace App\Entity\Billing;

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

/**
 * Paramètres généraux des exports de factures (Bill).
 */
// #[Auditable]
#[ApiResource(operations: [])]
#[ORM\Entity]
class BillingExportSetting
{
    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    #[ORM\ManyToOne]
    #[ORM\JoinColumn(nullable: true)]
    private ?SddTeneur $teneur = null;

    #[ORM\OneToOne(targetEntity: Organization::class, inversedBy: 'billingExportSetting', cascade: [])]
    protected ?Organization $organization;

    /** @var Collection<int, Access> */
    #[ORM\ManyToMany(targetEntity: Access::class, cascade: [], orphanRemoval: false)]
    protected Collection $stageManagers;

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

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

    public function getTeneur(): ?SddTeneur
    {
        return $this->teneur;
    }

    public function setTeneur(?SddTeneur $teneur): self
    {
        $this->teneur = $teneur;

        return $this;
    }

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

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

        return $this;
    }

    public function getStageManagers(): Collection
    {
        return $this->stageManagers;
    }

    public function addStageManager(Access $stageManager): self
    {
        if (!$this->stageManagers->contains($stageManager)) {
            $this->stageManagers[] = $stageManager;
            // TODO: compléter (je n'ai pas le mappedBy)
        }

        return $this;
    }

    public function removeStageManager(Access $stageManager): self
    {
        $this->stageManagers->removeElement($stageManager);

        // TODO: compléter (je n'ai pas le mappedBy)
        return $this;
    }
}
