src/Entity/EvaluationStatus.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\GetCollection;
  6. use App\Controller\Action\StatusWithEvaluationStatAction;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use ApiPlatform\Metadata\Post;
  11. #[ApiResource(
  12.     operations: [
  13.         new GetCollection(),
  14.         new Post(
  15.             uriTemplate'/evaluation_statuses/with_stat',
  16.             controllerStatusWithEvaluationStatAction::class,
  17.             readfalse,
  18.             writefalse,
  19.             name'_api_/evaluation_statuses/with_stat'
  20.         ),
  21.         new Get(),
  22.     ],
  23.     normalizationContext: ['groups' => ['compliance.get''evaluation.get''compliance:evaluation:get']]
  24. )]
  25. #[ORM\Entity]
  26. class EvaluationStatus
  27. {
  28.     #[ORM\Column(name'id'type'integer'nullablefalse)]
  29.     #[ORM\Id]
  30.     #[Groups(['compliance.get''evaluation.get''compliance:evaluation:get','plan.get'])]
  31.     private int $id;  
  32.     #[ORM\Column(nullabletrue)]
  33.     #[Groups(['compliance.get''evaluation.get''compliance:evaluation:get','plan.get'])]
  34.     private string $name;
  35.     #[ORM\OneToMany(mappedBy'status'targetEntityEvaluation::class)]
  36.     private Collection $evaluations;
  37.     #[ORM\Column(length255)]
  38.     #[Groups(['compliance.get''evaluation.get''compliance:evaluation:get','plan.get'])]
  39.     private ?string $color null;
  40.     public function getId():int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function setId(int $id)
  45.     {
  46.         $this->id $id;
  47.         return $this;
  48.     }
  49.     public function getName():string
  50.     {
  51.         return $this->name;
  52.     }
  53.     public function setName(?string $name): self
  54.     {
  55.         $this->name $name;
  56.         return $this;
  57.     }
  58.     public function getEvaluations(): Collection
  59.     {
  60.         return $this->evaluations;
  61.     }
  62.     public function addEvaluation(Evaluation $evaluation): self
  63.     {
  64.         if (!$this->evaluations->contains($evaluation)) {
  65.             $this->evaluations->add($evaluation);
  66.             $evaluation->setStatus($this);
  67.         }
  68.         return $this;
  69.     }
  70.     public function removeEvaluation(Evaluation $evaluation): self
  71.     {
  72.         if ($this->evaluations->removeElement($evaluation)) {
  73.             // set the owning side to null (unless already changed)
  74.             if ($evaluation->getDocument() === $this) {
  75.                 $evaluation->setStatus(null);
  76.             }
  77.         }
  78.         return $this;
  79.     }
  80.     public function getColor(): ?string
  81.     {
  82.         return $this->color;
  83.     }
  84.     public function setColor(string $color): self
  85.     {
  86.         $this->color $color;
  87.         return $this;
  88.     }
  89. }