<?php
namespace App\Entity;
use App\Repository\PermissionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PermissionRepository::class)]
class Permission
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $libelle;
#[ORM\ManyToMany(targetEntity: GroupePermission::class, mappedBy: 'permission')]
private $groupePermissions;
public function __construct()
{
$this->groupePermissions = 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, GroupePermission>
*/
public function getGroupePermissions(): Collection
{
return $this->groupePermissions;
}
public function addGroupePermission(GroupePermission $groupePermission): self
{
if (!$this->groupePermissions->contains($groupePermission)) {
$this->groupePermissions[] = $groupePermission;
$groupePermission->addPermission($this);
}
return $this;
}
public function removeGroupePermission(GroupePermission $groupePermission): self
{
if ($this->groupePermissions->removeElement($groupePermission)) {
$groupePermission->removePermission($this);
}
return $this;
}
public function __toString()
{
return $this->libelle;
}
}