<?php
declare (strict_types=1);

namespace App\Entity\Person;

use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\ApiResource;
use App\Entity\Access\Access;

//use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
use Doctrine\ORM\Mapping as ORM;

/**
 * Classe ... qui ...
 */
#[ApiResource(
    operations: [
        new Get(
            security: 'is_granted(\'ROLE_ADMIN\') and object.getAccess().getOrganization().getId() == user.getOrganization().getId()'
        )
    ]
)]
//#[Auditable]
#[ORM\Entity]
class CompanyPerson
{
    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    #[ORM\ManyToOne(inversedBy: 'companyPersonAccesses')]
    #[ORM\JoinColumn(nullable: false)]
    private Access $company;
    /**
     * @var Access
     */
    #[ORM\ManyToOne(inversedBy: 'companyPersonCompany')]
    #[ORM\JoinColumn(nullable: false)]
    private Access $access;

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

    public function getCompany(): ?Access
    {
        return $this->company;
    }

    public function setCompany(?Access $company): self
    {
        $this->company = $company;
        return $this;
    }

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

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