<?php
namespace App\Entity;
use App\Repository\RolesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=RolesRepository::class)
*/
class Roles
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\ManyToOne(targetEntity=Establishments::class, inversedBy="roles")
* @ORM\JoinColumn(nullable=false)
*/
private $establishment;
/**
* @ORM\Column(type="boolean")
*/
private $deleted = false;
/**
* @ORM\OneToMany(targetEntity=RolesAuthorizedActions::class, mappedBy="role")
*/
private $rolesAuthorizedActions;
/**
* @ORM\OneToMany(targetEntity=Users::class, mappedBy="role")
*/
private $users;
/**
* @ORM\Column(type="boolean")
*/
private $notRemovable = false;
/**
* @ORM\OneToMany(targetEntity=UserEstablishment::class, mappedBy="role")
*/
private $userEstablishments;
public function __construct()
{
$this->rolesAuthorizedActions = new ArrayCollection();
$this->users = new ArrayCollection();
$this->userEstablishments = 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 getEstablishment(): ?Establishments
{
return $this->establishment;
}
public function setEstablishment(?Establishments $establishment): self
{
$this->establishment = $establishment;
return $this;
}
public function isDeleted(): ?bool
{
return $this->deleted;
}
public function setDeleted(bool $deleted): self
{
$this->deleted = $deleted;
return $this;
}
/**
* @return Collection<int, RolesAuthorizedActions>
*/
public function getRolesAuthorizedActions(): Collection
{
return $this->rolesAuthorizedActions;
}
public function addRolesAuthorizedAction(RolesAuthorizedActions $rolesAuthorizedAction): self
{
if (!$this->rolesAuthorizedActions->contains($rolesAuthorizedAction)) {
$this->rolesAuthorizedActions[] = $rolesAuthorizedAction;
$rolesAuthorizedAction->setRole($this);
}
return $this;
}
public function removeRolesAuthorizedAction(RolesAuthorizedActions $rolesAuthorizedAction): self
{
if ($this->rolesAuthorizedActions->removeElement($rolesAuthorizedAction)) {
// set the owning side to null (unless already changed)
if ($rolesAuthorizedAction->getRole() === $this) {
$rolesAuthorizedAction->setRole(null);
}
}
return $this;
}
public function isNotRemovable(): ?bool
{
return $this->notRemovable;
}
public function setNotRemovable(bool $notRemovable): self
{
$this->notRemovable = $notRemovable;
return $this;
}
/**
* @return Collection<int, UserEstablishment>
*/
public function getUserEstablishments(): Collection
{
return $this->userEstablishments;
}
public function addUserEstablishment(UserEstablishment $userEstablishment): self
{
if (!$this->userEstablishments->contains($userEstablishment)) {
$this->userEstablishments[] = $userEstablishment;
$userEstablishment->setRole($this);
}
return $this;
}
public function removeUserEstablishment(UserEstablishment $userEstablishment): self
{
if ($this->userEstablishments->removeElement($userEstablishment)) {
// set the owning side to null (unless already changed)
if ($userEstablishment->getRole() === $this) {
$userEstablishment->setRole(null);
}
}
return $this;
}
}