src/Entity/Reference/ReferenceCollaboratorStatus.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Reference;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Entity\AbstractCollaborator;
  5. use App\Repository\Reference\ReferenceCollaboratorStatusRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. /**
  11.  * @ApiResource(
  12.  *     security= "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER') or is_granted('ROLE_IT')",
  13.  *     normalizationContext={"groups"={"reference-collaborator-status:read"}, "swagger_definition_name"="Read"},
  14.  *     denormalizationContext={"groups"={"reference-collaborator-status:write"}, "swagger_definition_name"="Write"},
  15.  *     itemOperations={
  16.  *          "get"
  17.  *     },
  18.  *     collectionOperations={
  19.  *           "get",
  20.  *
  21.  *     },
  22.  *     attributes={
  23.  *          "pagination_items_per_page"=10,
  24.  *          "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
  25.  *     }
  26.  * )
  27.  *
  28.  * @ORM\Entity(repositoryClass=ReferenceCollaboratorStatusRepository::class)
  29.  */
  30. class ReferenceCollaboratorStatus
  31. {
  32.     public const TRANSLATION_DOMAIN 'reference_collaborator';
  33.     public const REFERENCE_COLLABORATOR_STATUS_AGENT 'reference.collaborator.status.AGENT';
  34.     public const REFERENCE_COLLABORATOR_STATUS_CHEF 'reference.collaborator.status.CHEF';
  35.     public const REFERENCE_COLLABORATOR_STATUS_PRESCRIBER 'reference.collaborator.status.PRESCRIBER';
  36.     public const REFERENCE_COLLABORATOR_STATUS_HEAD_OF_CONSTELLATION 'reference.collaborator.status.HEAD_OF_CONSTELLATION';
  37.     public const REFERENCE_COLLABORATOR_STATUS_RECOMMENDER 'reference.collaborator.status.RECOMMENDER';
  38.     public const ALL_REFERENCE_COLLABORATOR_STATUS = [
  39.         self::REFERENCE_COLLABORATOR_STATUS_AGENT,
  40.         self::REFERENCE_COLLABORATOR_STATUS_CHEF,
  41.         self::REFERENCE_COLLABORATOR_STATUS_PRESCRIBER,
  42.         self::REFERENCE_COLLABORATOR_STATUS_HEAD_OF_CONSTELLATION,
  43.         self::REFERENCE_COLLABORATOR_STATUS_RECOMMENDER
  44.     ];
  45.     public const REFERENCE_CODE_COLLABORATOR_STATUS_AGENT '1';
  46.     public const REFERENCE_CODE_COLLABORATOR_STATUS_CHEF '2';
  47.     public const REFERENCE_CODE_COLLABORATOR_STATUS_PRESCRIBER '3';
  48.     public const REFERENCE_CODE_COLLABORATOR_STATUS_HEAD_OF_CONSTELLATION '4';
  49.     public const REFERENCE_CODE_COLLABORATOR_STATUS_RECOMMENDER '5';
  50.     public const ALL_REFERENCE_CODE_STATUS = [
  51.         self::REFERENCE_CODE_COLLABORATOR_STATUS_AGENT,
  52.         self::REFERENCE_CODE_COLLABORATOR_STATUS_CHEF,
  53.         self::REFERENCE_CODE_COLLABORATOR_STATUS_PRESCRIBER,
  54.         self::REFERENCE_CODE_COLLABORATOR_STATUS_HEAD_OF_CONSTELLATION,
  55.         self::REFERENCE_CODE_COLLABORATOR_STATUS_RECOMMENDER
  56.     ];
  57.     /**
  58.      * @ORM\Id
  59.      * @ORM\GeneratedValue
  60.      * @ORM\Column(type="integer")
  61.      *
  62.      * @Groups({
  63.      *     "reference-collaborator-status:read",
  64.      *     "directory:collaborator:search",
  65.      *     "abstract-colloborator:read",
  66.      *     "agent:read"
  67.      *  })
  68.      *
  69.      */
  70.     private $id;
  71.     /**
  72.      * @ORM\Column(type="string", length=255)
  73.      *
  74.      * @Groups({
  75.      *     "reference-collaborator-status:read",
  76.      *     "directory:collaborator:search",
  77.      *     "abstract-colloborator:read",
  78.      *     "agent:read"
  79.      *  })
  80.      *
  81.      */
  82.     private ?string $name;
  83.     /**
  84.      * @ORM\Column(type="string", length=255)
  85.      *
  86.      * @Groups({
  87.      *     "reference-collaborator-status:read",
  88.      *     "directory:collaborator:search",
  89.      *     "abstract-colloborator:read",
  90.      *     "agent:read"
  91.      *  })
  92.      */
  93.     private ?string $code;
  94.     /**
  95.      * @ORM\OneToMany(targetEntity=AbstractCollaborator::class, mappedBy="referenceStatus")
  96.      */
  97.     private $collaborators;
  98.     public function __construct()
  99.     {
  100.         $this->collaborators = new ArrayCollection();
  101.     }
  102.     public function getId(): ?int
  103.     {
  104.         return $this->id;
  105.     }
  106.     public function getName(): ?string
  107.     {
  108.         return $this->name;
  109.     }
  110.     public function setName(string $name): self
  111.     {
  112.         $this->name $name;
  113.         return $this;
  114.     }
  115.     /**
  116.      * @return Collection<int, AbstractCollaborator>
  117.      */
  118.     public function getCollaborators(): Collection
  119.     {
  120.         return $this->collaborators;
  121.     }
  122.     public function addCollaborator(AbstractCollaborator $collaborator): self
  123.     {
  124.         if (!$this->collaborators->contains($collaborator)) {
  125.             $this->collaborators[] = $collaborator;
  126.             $collaborator->setReferenceStatus($this);
  127.         }
  128.         return $this;
  129.     }
  130.     public function removeCollaborator(AbstractCollaborator $collaborator): self
  131.     {
  132.         if ($this->collaborators->removeElement($collaborator)) {
  133.             // set the owning side to null (unless already changed)
  134.             if ($collaborator->getReferenceStatus() === $this) {
  135.                 $collaborator->setReferenceStatus(null);
  136.             }
  137.         }
  138.         return $this;
  139.     }
  140.     public function getCode(): ?string
  141.     {
  142.         return $this->code;
  143.     }
  144.     public function setCode(string $code): self
  145.     {
  146.         $this->code $code;
  147.         return $this;
  148.     }
  149. }