<?php

namespace AppBundle\Entity\Person;

use AppBundle\Entity\AccessAndFunction\Access;
use AppBundle\Entity\Traits\ActivityPeriodTrait;
use Doctrine\ORM\Mapping as ORM;
use Dunglas\ApiBundle\Annotation\Iri;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Entity\Traits\TimestampableEntity;
use AppBundle\Entity\Traits\CreatorUpdaterEntity;

/**
 * Rôle d'un Access d'une personne physique dans un Access d'une personne morale
 *
 * @Iri("http://schema.org/CompanyPerson")
 */
#[ORM\Entity]
class CompanyPerson
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    use ActivityPeriodTrait;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['othercontact_list', 'othercontact_list_companypersoncompany', 'companyperson', 'access_details', 'morals_list'])]
    private $id;
    /**
     * @var Access
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'companyPersonAccesses')]
    #[ORM\JoinColumn(nullable: false)]
    #[Assert\NotNull]
    #[Groups(['companyperson', 'othercontact_list_companypersoncompany', 'access_details_companypersonaccesses', 'access_details_companypersoncompany'])]
    private $company;
    /**
     * @var Access
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'companyPersonCompany')]
    #[ORM\JoinColumn(nullable: false)]
    #[Assert\NotNull]
    #[Groups(['companyperson', 'access_details_companypersonaccesses', 'morals_list_companypersonaccesses'])]
    private $access;
    /**
     * @var string
     */
    #[ORM\Column(type: 'text', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['companyperson', 'othercontact_list_companypersoncompany', 'access_details_companypersonaccesses', 'access_details_companypersoncompany'])]
    private $mission;
    /**
     * @var string
     */
    #[Groups(['othercontact_list_companypersoncompany'])]
    private $companyFullLabelTemplate;
    /**
     * Sets id.
     * 
     * @param int $id
     * 
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }
    /**
     * Gets id.
     * 
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * Sets company.
     * 
     * @param Access $company
     * 
     * @return $this
     */
    public function setCompany(Access $company)
    {
        $this->company = $company;

        return $this;
    }
    /**
     * Gets company.
     * 
     * @return Access
     */
    public function getCompany()
    {
        return $this->company;
    }
    /**
     * Sets person.
     * 
     * @param Access $access
     * 
     * @return $this
     */
    public function setAccess(Access $access)
    {
        $this->access = $access;

        return $this;
    }
    /**
     * Gets person.
     * 
     * @return Access
     */
    public function getAccess()
    {
        return $this->access;
    }
    /**
     * Sets mission.
     * 
     * @param string $mission
     * 
     * @return $this
     */
    public function setMission($mission)
    {
        $this->mission = $mission;

        return $this;
    }
    /**
     * Gets mission.
     * 
     * @return string
     */
    public function getMission()
    {
        return $this->mission;
    }
    /**
     * Gets full label.
     *
     * @return string
     */
    public function getCompanyFullLabelTemplate()
    {
        return [
            $this->getCompany()->getPerson()->getName(),
            $this->getMission()
        ];
    }
}
