<?php

declare(strict_types=1);

namespace App\Entity\Core;

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

/**
 * Affiche une modale d'information à la connexion de l'utilisateur.
 */
// #[Auditable]
#[ApiResource(operations: [])]
// #[Auditable]
#[ORM\Entity]
class Tips extends AbstractInformation
{
    /** @var Collection<int, Organization> */
    #[ORM\ManyToMany(targetEntity: Organization::class, mappedBy: 'tips', cascade: [], orphanRemoval: false)]
    protected Collection $organizations;

    public function __construct()
    {
        $this->organizations = new ArrayCollection();
        parent::__construct();
    }

    public function getOrganizations(): Collection
    {
        return $this->organizations;
    }

    public function addOrganization(Organization $organization): self
    {
        if (!$this->organizations->contains($organization)) {
            $this->organizations[] = $organization;
            $organization->addTip($this);
        }

        return $this;
    }

    public function removeOrganization(Organization $organization): self
    {
        if ($this->organizations->removeElement($organization)) {
            $organization->removeTip($this);
        }

        return $this;
    }
}
