<?php
namespace App\Entity;
use App\Repository\AccessModulesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=AccessModulesRepository::class)
* @UniqueEntity(
* fields={"module_key", "module_display_name"},
* message="Access module already registered|Access module with combination (%s %s) is already registered"
* )
*/
class AccessModules
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "right.module.core",
* "user_right_module@core",
* "user_right_module@open_api",
*
* "access_module@core"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "right.module.core",
* "user_right_module@core",
* "user_right_module@open_api",
*
* "access_module@core"
* })
*/
private $module_key;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "right.module.core",
* "user_right_module@core",
* "user_right_module@open_api",
*
* "access_module@core"
* })
*/
private $module_display_name;
/**
* @ORM\OneToMany(targetEntity=UserModulePermissions::class, mappedBy="access_module")
*/
private $user_module_permissions;
/**
* @ORM\Column(type="json", nullable=true)
* @Groups({
* "right.module.core",
*
*
* "access_module@core"
* })
*/
private $manageable_actions = [];
/**
* @ORM\OneToMany(targetEntity=AccessModuleSections::class, mappedBy="access_module")
* @Groups({"right.module.sections"})
* @Groups({
* "user_right_module@sections",
*
* "access_module@sections"
* })
*/
private $access_module_sections;
/**
* @ORM\Column(type="access_module_role_type", nullable=true)
* @Groups({
* "access_module@core"
* })
*/
private $access_module_role;
public function __construct()
{
$this->user_permissions = new ArrayCollection();
$this->access_module_sections = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getModuleKey(): ?string
{
return $this->module_key;
}
public function setModuleKey(?string $module_key): self
{
$this->module_key = $module_key;
return $this;
}
public function getModuleDisplayName(): ?string
{
return $this->module_display_name;
}
public function setModuleDisplayName(?string $module_display_name): self
{
$this->module_display_name = $module_display_name;
return $this;
}
/**
* @return Collection<int, UserModulePermissions>
*/
public function getUserPermissions(): Collection
{
return $this->user_permissions;
}
public function addUserRight(UserModulePermissions $userRight): self
{
if (!$this->user_permissions->contains($userRight)) {
$this->user_permissions[] = $userRight;
$userRight->setRightModule($this);
}
return $this;
}
public function removeUserRight(UserModulePermissions $userRight): self
{
if ($this->user_permissions->removeElement($userRight)) {
// set the owning side to null (unless already changed)
if ($userRight->getRightModule() === $this) {
$userRight->setRightModule(null);
}
}
return $this;
}
public function getManageableActions(): ?array
{
return $this->manageable_actions;
}
public function setManageableActions(?array $manageable_actions): self
{
$this->manageable_actions = $manageable_actions;
return $this;
}
/**
* @return Collection<int, AccessModuleSections>
*/
public function getAccessmoduleSections(): Collection
{
return $this->access_module_sections;
}
public function addUserRightModulesSection(AccessModuleSections $userRightModulesSection): self
{
if (!$this->access_module_sections->contains($userRightModulesSection)) {
$this->access_module_sections[] = $userRightModulesSection;
$userRightModulesSection->setAccessModule($this);
}
return $this;
}
public function removeUserRightModulesSection(AccessModuleSections $userRightModulesSection): self
{
if ($this->access_module_sections->removeElement($userRightModulesSection)) {
// set the owning side to null (unless already changed)
if ($userRightModulesSection->getAccessModule() === $this) {
$userRightModulesSection->setAccessModule(null);
}
}
return $this;
}
public function getAccessModuleRole()
{
return $this->access_module_role;
}
public function setAccessModuleRole($access_module_role): self
{
$this->access_module_role = $access_module_role;
return $this;
}
}