src/Entity/PerformenceCritere.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\TimeStampable;
  4. use App\Repository\PerformenceCritereRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClass: PerformenceCritereRepository::class)]
  12. #[UniqueEntity(
  13.     fields: ['name',],
  14.     errorPath: 'name',
  15.     message: 'Le nom que vous avez saisi est déjà utilisé',
  16. )]
  17. #[ORM\HasLifecycleCallbacks]
  18. class PerformenceCritere
  19. {
  20.     use TimeStampable;
  21.     #[ORM\Id]
  22.     #[ORM\GeneratedValue]
  23.     #[ORM\Column]
  24.     #[Groups(['entity:write', 'critere:read', 'evaluationCritere:read'])]
  25.     private ?int $id = null;
  26.     #[ORM\Column(length: 255)]
  27.     #[Groups(['entity:write', 'critere:read', 'evaluationCritere:read'])]
  28.     #[Assert\NotBlank(message: "Veuillez remplir ce champ")]
  29.     private ?string $name = null;
  30.     #[ORM\Column]
  31.     #[Groups(['entity:write', 'critere:read', 'evaluationCritere:read'])]
  32.     #[Assert\NotBlank(message: "Veuillez remplir ce champ")]
  33.     private ?int $cible = null;
  34.     #[ORM\OneToMany(mappedBy: 'critere', targetEntity: EvaluationCritere::class)]
  35.     #[Groups(['critere:read'])]
  36.     private Collection $evaluationCriteres;
  37.     public function __construct()
  38.     {
  39.         $this->createdAt = new \DateTimeImmutable();
  40.         $this->updatedAt = new \DateTimeImmutable();
  41.         $this->evaluationCriteres = new ArrayCollection();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getName(): ?string
  48.     {
  49.         return $this->name;
  50.     }
  51.     public function setName(string $name): static
  52.     {
  53.         $this->name = $name;
  54.         return $this;
  55.     }
  56.     public function getCible(): ?int
  57.     {
  58.         return $this->cible;
  59.     }
  60.     public function setCible(int $cible): static
  61.     {
  62.         $this->cible = $cible;
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return Collection<int, EvaluationCritere>
  67.      */
  68.     public function getEvaluationCriteres(): Collection
  69.     {
  70.         return $this->evaluationCriteres;
  71.     }
  72.     public function addEvaluationCritere(EvaluationCritere $evaluationCritere): static
  73.     {
  74.         if (!$this->evaluationCriteres->contains($evaluationCritere)) {
  75.             $this->evaluationCriteres->add($evaluationCritere);
  76.             $evaluationCritere->setCritere($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeEvaluationCritere(EvaluationCritere $evaluationCritere): static
  81.     {
  82.         if ($this->evaluationCriteres->removeElement($evaluationCritere)) {
  83.             // set the owning side to null (unless already changed)
  84.             if ($evaluationCritere->getCritere() === $this) {
  85.                 $evaluationCritere->setCritere(null);
  86.             }
  87.         }
  88.         return $this;
  89.     }
  90. }