src/Entity/AccessModules.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AccessModulesRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. /**
  10.  * @ORM\Entity(repositoryClass=AccessModulesRepository::class)
  11.  * @UniqueEntity(
  12.  *      fields={"module_key", "module_display_name"},
  13.  *      message="Access module already registered|Access module with combination (%s %s) is already registered"
  14.  *  )
  15.  */
  16. class AccessModules
  17. {
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      * @Groups({
  23.      *     "right.module.core",
  24.      *     "user_right_module@core",
  25.      *     "user_right_module@open_api",
  26.      *
  27.      *     "access_module@core"
  28.      * })
  29.      */
  30.     private $id;
  31.     /**
  32.      * @ORM\Column(type="string", length=64, nullable=true)
  33.      * @Groups({
  34.      *     "right.module.core",
  35.      *     "user_right_module@core",
  36.      *     "user_right_module@open_api",
  37.      *
  38.      *     "access_module@core"
  39.      * })
  40.      */
  41.     private $module_key;
  42.     /**
  43.      * @ORM\Column(type="string", length=64, nullable=true)
  44.      * @Groups({
  45.      *     "right.module.core",
  46.      *     "user_right_module@core",
  47.      *     "user_right_module@open_api",
  48.      *
  49.      *     "access_module@core"
  50.      * })
  51.      */
  52.     private $module_display_name;
  53.     /**
  54.      * @ORM\OneToMany(targetEntity=UserModulePermissions::class, mappedBy="access_module")
  55.      */
  56.     private $user_module_permissions;
  57.     /**
  58.      * @ORM\Column(type="json", nullable=true)
  59.      * @Groups({
  60.      *     "right.module.core",
  61.      *
  62.      *
  63.      *     "access_module@core"
  64.      * })
  65.      */
  66.     private $manageable_actions = [];
  67.     /**
  68.      * @ORM\OneToMany(targetEntity=AccessModuleSections::class, mappedBy="access_module")
  69.      * @Groups({"right.module.sections"})
  70.      * @Groups({
  71.      *     "user_right_module@sections",
  72.      *
  73.      *     "access_module@sections"
  74.      * })
  75.      */
  76.     private $access_module_sections;
  77.     /**
  78.      * @ORM\Column(type="access_module_role_type", nullable=true)
  79.      * @Groups({
  80.      *     "access_module@core"
  81.      * })
  82.      */
  83.     private $access_module_role;
  84.     public function __construct()
  85.     {
  86.         $this->user_permissions = new ArrayCollection();
  87.         $this->access_module_sections = new ArrayCollection();
  88.     }
  89.     public function getId(): ?int
  90.     {
  91.         return $this->id;
  92.     }
  93.     public function getModuleKey(): ?string
  94.     {
  95.         return $this->module_key;
  96.     }
  97.     public function setModuleKey(?string $module_key): self
  98.     {
  99.         $this->module_key $module_key;
  100.         return $this;
  101.     }
  102.     public function getModuleDisplayName(): ?string
  103.     {
  104.         return $this->module_display_name;
  105.     }
  106.     public function setModuleDisplayName(?string $module_display_name): self
  107.     {
  108.         $this->module_display_name $module_display_name;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @return Collection<int, UserModulePermissions>
  113.      */
  114.     public function getUserPermissions(): Collection
  115.     {
  116.         return $this->user_permissions;
  117.     }
  118.     public function addUserRight(UserModulePermissions $userRight): self
  119.     {
  120.         if (!$this->user_permissions->contains($userRight)) {
  121.             $this->user_permissions[] = $userRight;
  122.             $userRight->setRightModule($this);
  123.         }
  124.         return $this;
  125.     }
  126.     public function removeUserRight(UserModulePermissions $userRight): self
  127.     {
  128.         if ($this->user_permissions->removeElement($userRight)) {
  129.             // set the owning side to null (unless already changed)
  130.             if ($userRight->getRightModule() === $this) {
  131.                 $userRight->setRightModule(null);
  132.             }
  133.         }
  134.         return $this;
  135.     }
  136.     public function getManageableActions(): ?array
  137.     {
  138.         return $this->manageable_actions;
  139.     }
  140.     public function setManageableActions(?array $manageable_actions): self
  141.     {
  142.         $this->manageable_actions $manageable_actions;
  143.         return $this;
  144.     }
  145.     /**
  146.      * @return Collection<int, AccessModuleSections>
  147.      */
  148.     public function getAccessmoduleSections(): Collection
  149.     {
  150.         return $this->access_module_sections;
  151.     }
  152.     public function addUserRightModulesSection(AccessModuleSections $userRightModulesSection): self
  153.     {
  154.         if (!$this->access_module_sections->contains($userRightModulesSection)) {
  155.             $this->access_module_sections[] = $userRightModulesSection;
  156.             $userRightModulesSection->setAccessModule($this);
  157.         }
  158.         return $this;
  159.     }
  160.     public function removeUserRightModulesSection(AccessModuleSections $userRightModulesSection): self
  161.     {
  162.         if ($this->access_module_sections->removeElement($userRightModulesSection)) {
  163.             // set the owning side to null (unless already changed)
  164.             if ($userRightModulesSection->getAccessModule() === $this) {
  165.                 $userRightModulesSection->setAccessModule(null);
  166.             }
  167.         }
  168.         return $this;
  169.     }
  170.     public function getAccessModuleRole()
  171.     {
  172.         return $this->access_module_role;
  173.     }
  174.     public function setAccessModuleRole($access_module_role): self
  175.     {
  176.         $this->access_module_role $access_module_role;
  177.         return $this;
  178.     }
  179. }