<?php
namespace App\Entity\Reference;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\AbstractCollaborator;
use App\Repository\Reference\ReferenceCollaboratorStatusRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* security= "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER') or is_granted('ROLE_IT')",
* normalizationContext={"groups"={"reference-collaborator-status:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"reference-collaborator-status:write"}, "swagger_definition_name"="Write"},
* itemOperations={
* "get"
* },
* collectionOperations={
* "get",
*
* },
* attributes={
* "pagination_items_per_page"=10,
* "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
* }
* )
*
* @ORM\Entity(repositoryClass=ReferenceCollaboratorStatusRepository::class)
*/
class ReferenceCollaboratorStatus
{
public const TRANSLATION_DOMAIN = 'reference_collaborator';
public const REFERENCE_COLLABORATOR_STATUS_AGENT = 'reference.collaborator.status.AGENT';
public const REFERENCE_COLLABORATOR_STATUS_CHEF = 'reference.collaborator.status.CHEF';
public const REFERENCE_COLLABORATOR_STATUS_PRESCRIBER = 'reference.collaborator.status.PRESCRIBER';
public const REFERENCE_COLLABORATOR_STATUS_HEAD_OF_CONSTELLATION = 'reference.collaborator.status.HEAD_OF_CONSTELLATION';
public const REFERENCE_COLLABORATOR_STATUS_RECOMMENDER = 'reference.collaborator.status.RECOMMENDER';
public const ALL_REFERENCE_COLLABORATOR_STATUS = [
self::REFERENCE_COLLABORATOR_STATUS_AGENT,
self::REFERENCE_COLLABORATOR_STATUS_CHEF,
self::REFERENCE_COLLABORATOR_STATUS_PRESCRIBER,
self::REFERENCE_COLLABORATOR_STATUS_HEAD_OF_CONSTELLATION,
self::REFERENCE_COLLABORATOR_STATUS_RECOMMENDER
];
public const REFERENCE_CODE_COLLABORATOR_STATUS_AGENT = '1';
public const REFERENCE_CODE_COLLABORATOR_STATUS_CHEF = '2';
public const REFERENCE_CODE_COLLABORATOR_STATUS_PRESCRIBER = '3';
public const REFERENCE_CODE_COLLABORATOR_STATUS_HEAD_OF_CONSTELLATION = '4';
public const REFERENCE_CODE_COLLABORATOR_STATUS_RECOMMENDER = '5';
public const ALL_REFERENCE_CODE_STATUS = [
self::REFERENCE_CODE_COLLABORATOR_STATUS_AGENT,
self::REFERENCE_CODE_COLLABORATOR_STATUS_CHEF,
self::REFERENCE_CODE_COLLABORATOR_STATUS_PRESCRIBER,
self::REFERENCE_CODE_COLLABORATOR_STATUS_HEAD_OF_CONSTELLATION,
self::REFERENCE_CODE_COLLABORATOR_STATUS_RECOMMENDER
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Groups({
* "reference-collaborator-status:read",
* "directory:collaborator:search",
* "abstract-colloborator:read",
* "agent:read"
* })
*
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "reference-collaborator-status:read",
* "directory:collaborator:search",
* "abstract-colloborator:read",
* "agent:read"
* })
*
*/
private ?string $name;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "reference-collaborator-status:read",
* "directory:collaborator:search",
* "abstract-colloborator:read",
* "agent:read"
* })
*/
private ?string $code;
/**
* @ORM\OneToMany(targetEntity=AbstractCollaborator::class, mappedBy="referenceStatus")
*/
private $collaborators;
public function __construct()
{
$this->collaborators = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, AbstractCollaborator>
*/
public function getCollaborators(): Collection
{
return $this->collaborators;
}
public function addCollaborator(AbstractCollaborator $collaborator): self
{
if (!$this->collaborators->contains($collaborator)) {
$this->collaborators[] = $collaborator;
$collaborator->setReferenceStatus($this);
}
return $this;
}
public function removeCollaborator(AbstractCollaborator $collaborator): self
{
if ($this->collaborators->removeElement($collaborator)) {
// set the owning side to null (unless already changed)
if ($collaborator->getReferenceStatus() === $this) {
$collaborator->setReferenceStatus(null);
}
}
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
}