<?phpnamespace App\Entity;use App\Repository\RoleRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=RoleRepository::class) */class Role{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $libelle; /** * @ORM\OneToMany(targetEntity=User::class, mappedBy="role") */ private $users; /** * @ORM\ManyToMany(targetEntity=Fonction::class, mappedBy="role") */ private $fonctions; public function __construct() { $this->users = new ArrayCollection(); $this->fonctions = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getLibelle(): ?string { return $this->libelle; } public function setLibelle(string $libelle): self { $this->libelle = $libelle; return $this; } /** * @return Collection<int, User> */ public function getUsers(): Collection { return $this->users; } public function addUser(User $user): self { if (!$this->users->contains($user)) { $this->users[] = $user; $user->setRole($this); } return $this; } public function removeUser(User $user): self { if ($this->users->removeElement($user)) { // set the owning side to null (unless already changed) if ($user->getRole() === $this) { $user->setRole(null); } } return $this; } /** * @return Collection<int, Fonction> */ public function getFonctions(): Collection { return $this->fonctions; } public function addFonction(Fonction $fonction): self { if (!$this->fonctions->contains($fonction)) { $this->fonctions[] = $fonction; $fonction->addRole($this); } return $this; } public function removeFonction(Fonction $fonction): self { if ($this->fonctions->removeElement($fonction)) { $fonction->removeRole($this); } return $this; }}