<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
#[ORM\Entity(repositoryClass: 'App\Repository\RoleRepository')]
#[UniqueEntity(fields: ['name'])]
class Role
{
const ROLE_USER = 2;
const USER = 'User';
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(['default', 'backend'])]
private ?string $name = null;
#[ORM\ManyToMany(targetEntity: 'App\Entity\Permission')]
private Collection $permissions;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $displayName = null;
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isBaseRole = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $ordering = null;
public function __construct()
{
$this->permissions = 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;
}
/**
* @return Collection|Permission[]
*/
public function getPermissions(): Collection
{
return $this->permissions;
}
public function addPermission(Permission $permission): self
{
if (!$this->permissions->contains($permission)) {
$this->permissions[] = $permission;
}
return $this;
}
public function removePermission(Permission $permission): self
{
if ($this->permissions->contains($permission)) {
$this->permissions->removeElement($permission);
}
return $this;
}
public function getDisplayName(): ?string
{
return $this->displayName;
}
public function setDisplayName(?string $displayName): self
{
$this->displayName = $displayName;
return $this;
}
public function getIsBaseRole(): ?bool
{
return $this->isBaseRole;
}
public function setIsBaseRole(?bool $isBaseRole): self
{
$this->isBaseRole = $isBaseRole;
return $this;
}
public function getOrdering(): ?int
{
return $this->ordering;
}
public function setOrdering(?int $ordering): self
{
$this->ordering = $ordering;
return $this;
}
}