src/Entity/SousSysteme.php line 20
<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use App\Repository\SousSystemeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: SousSystemeRepository::class)]
#[ApiResource(
operations: [
new GetCollection()
]
)]
class SousSysteme
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['read:classe:collection', 'read:user:item'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Assert\NotBlank(message: "Ne peut ĂȘtre vide !")]
#[Assert\NotNull(message: "Ne peut ĂȘtre nul !")]
#[Groups(['read:classe:collection', 'read:user:item'])]
private ?string $name = null;
#[ORM\Column(length: 255)]
#[Groups(['read:classe:collection', 'read:user:item'])]
private ?string $slug = null;
#[ORM\ManyToMany(targetEntity: Filiere::class, mappedBy: 'sousSysteme')]
private Collection $filieres;
#[ORM\OneToMany(mappedBy: 'sousSysteme', targetEntity: Classe::class)]
private Collection $classes;
public function __construct()
{
$this->filieres = new ArrayCollection();
$this->classes = 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;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, Filiere>
*/
public function getFilieres(): Collection
{
return $this->filieres;
}
public function addFiliere(Filiere $filiere): self
{
if (!$this->filieres->contains($filiere)) {
$this->filieres->add($filiere);
$filiere->addSousSysteme($this);
}
return $this;
}
public function removeFiliere(Filiere $filiere): self
{
if ($this->filieres->removeElement($filiere)) {
$filiere->removeSousSysteme($this);
}
return $this;
}
/**
* @return Collection<int, Classe>
*/
public function getClasses(): Collection
{
return $this->classes;
}
public function addClass(Classe $class): self
{
if (!$this->classes->contains($class)) {
$this->classes->add($class);
$class->setSousSysteme($this);
}
return $this;
}
public function removeClass(Classe $class): self
{
if ($this->classes->removeElement($class)) {
// set the owning side to null (unless already changed)
if ($class->getSousSysteme() === $this) {
$class->setSousSysteme(null);
}
}
return $this;
}
}