<?php
namespace App\Entity;
use App\Repository\UserRightsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping\UniqueConstraint;
/**
* @ORM\Entity(repositoryClass=UserRightsRepository::class)
* @ORM\Table(name="user_rights", uniqueConstraints={
* @UniqueConstraint(name="user_unique_right", columns={"user_id", "user_right_module_id"})
* })
*/
class UserRights
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"user.right.core"})
*/
private $id;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups({"user.right.core"})
*/
private $can_insert;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups({"user.right.core"})
*/
private $can_edit;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups({"user.right.core"})
*/
private $can_delete;
/**
* @ORM\ManyToOne(targetEntity=UserRightModules::class, inversedBy="userRights")
* @Groups({"user.right.module.ref"})
*/
private $user_right_module;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="userRights")
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $user;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups({"user.right.core"})
*/
private $can_read;
/**
* @ORM\OneToMany(targetEntity=UserRightsModuleSectionRights::class, mappedBy="userRights", orphanRemoval=true, cascade={"persist"})
* @Groups({"user.right.module.section.rights"})
*/
private $user_rights_module_section_rights;
public function __construct()
{
$this->user_rights_module_section_rights = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function isCanInsert(): ?bool
{
return $this->can_insert;
}
public function setCanInsert(?bool $can_insert): self
{
$this->can_insert = $can_insert;
return $this;
}
public function isCanEdit(): ?bool
{
return $this->can_edit;
}
public function setCanEdit(?bool $can_edit): self
{
$this->can_edit = $can_edit;
return $this;
}
public function isCanDelete(): ?bool
{
return $this->can_delete;
}
public function setCanDelete(?bool $can_delete): self
{
$this->can_delete = $can_delete;
return $this;
}
public function getUserRightModule(): ?UserRightModules
{
return $this->user_right_module;
}
public function setUserRightModule(?UserRightModules $user_right_module): self
{
$this->user_right_module = $user_right_module;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function isCanRead(): ?bool
{
return $this->can_read;
}
public function setCanRead(?bool $can_read): self
{
$this->can_read = $can_read;
return $this;
}
/**
* @return Collection<int, UserRightsModuleSectionRights>
*/
public function getUserRightsModuleSectionRights(): Collection
{
return $this->user_rights_module_section_rights;
}
public function addUserRightsModuleSectionRight(UserRightsModuleSectionRights $userRightsModuleSectionRight): self
{
if (!$this->user_rights_module_section_rights->contains($userRightsModuleSectionRight)) {
$this->user_rights_module_section_rights[] = $userRightsModuleSectionRight;
$userRightsModuleSectionRight->setUserRights($this);
}
return $this;
}
public function removeUserRightsModuleSectionRight(UserRightsModuleSectionRights $userRightsModuleSectionRight): self
{
if ($this->user_rights_module_section_rights->removeElement($userRightsModuleSectionRight)) {
// set the owning side to null (unless already changed)
if ($userRightsModuleSectionRight->getUserRights() === $this) {
$userRightsModuleSectionRight->setUserRights(null);
}
}
return $this;
}
}