src/Entity/SousSysteme.php line 20

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use App\Repository\SousSystemeRepository;
  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. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClassSousSystemeRepository::class)]
  12. #[ApiResource(
  13.     operations: [
  14.         new GetCollection()
  15.     ]
  16. )]
  17. class SousSysteme
  18. {
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue]
  21.     #[ORM\Column]
  22.     #[Groups(['read:classe:collection''read:user:item'])]
  23.     private ?int $id null;
  24.     #[ORM\Column(length255)]
  25.     #[Assert\NotBlank(message"Ne peut ĂȘtre vide !")]
  26.     #[Assert\NotNull(message"Ne peut ĂȘtre nul !")]
  27.     #[Groups(['read:classe:collection''read:user:item'])]
  28.     private ?string $name null;
  29.     #[ORM\Column(length255)]
  30.     #[Groups(['read:classe:collection''read:user:item'])]
  31.     private ?string $slug null;
  32.     #[ORM\ManyToMany(targetEntityFiliere::class, mappedBy'sousSysteme')]
  33.     private Collection $filieres;
  34.     #[ORM\OneToMany(mappedBy'sousSysteme'targetEntityClasse::class)]
  35.     private Collection $classes;
  36.     public function __construct()
  37.     {
  38.         $this->filieres = new ArrayCollection();
  39.         $this->classes = new ArrayCollection();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getName(): ?string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function setName(string $name): self
  50.     {
  51.         $this->name $name;
  52.         return $this;
  53.     }
  54.     public function getSlug(): ?string
  55.     {
  56.         return $this->slug;
  57.     }
  58.     public function setSlug(string $slug): self
  59.     {
  60.         $this->slug $slug;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return Collection<int, Filiere>
  65.      */
  66.     public function getFilieres(): Collection
  67.     {
  68.         return $this->filieres;
  69.     }
  70.     public function addFiliere(Filiere $filiere): self
  71.     {
  72.         if (!$this->filieres->contains($filiere)) {
  73.             $this->filieres->add($filiere);
  74.             $filiere->addSousSysteme($this);
  75.         }
  76.         return $this;
  77.     }
  78.     public function removeFiliere(Filiere $filiere): self
  79.     {
  80.         if ($this->filieres->removeElement($filiere)) {
  81.             $filiere->removeSousSysteme($this);
  82.         }
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection<int, Classe>
  87.      */
  88.     public function getClasses(): Collection
  89.     {
  90.         return $this->classes;
  91.     }
  92.     public function addClass(Classe $class): self
  93.     {
  94.         if (!$this->classes->contains($class)) {
  95.             $this->classes->add($class);
  96.             $class->setSousSysteme($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeClass(Classe $class): self
  101.     {
  102.         if ($this->classes->removeElement($class)) {
  103.             // set the owning side to null (unless already changed)
  104.             if ($class->getSousSysteme() === $this) {
  105.                 $class->setSousSysteme(null);
  106.             }
  107.         }
  108.         return $this;
  109.     }
  110. }