src/Entity/UserRights.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRightsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Doctrine\ORM\Mapping\UniqueConstraint;
  9. /**
  10.  * @ORM\Entity(repositoryClass=UserRightsRepository::class)
  11.  * @ORM\Table(name="user_rights", uniqueConstraints={
  12.  *     @UniqueConstraint(name="user_unique_right", columns={"user_id", "user_right_module_id"})
  13.  * })
  14.  */
  15. class UserRights
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      * @Groups({"user.right.core"})
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="boolean", nullable=true)
  26.      * @Groups({"user.right.core"})
  27.      */
  28.     private $can_insert;
  29.     /**
  30.      * @ORM\Column(type="boolean", nullable=true)
  31.      * @Groups({"user.right.core"})
  32.      */
  33.     private $can_edit;
  34.     /**
  35.      * @ORM\Column(type="boolean", nullable=true)
  36.      * @Groups({"user.right.core"})
  37.      */
  38.     private $can_delete;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity=UserRightModules::class, inversedBy="userRights")
  41.      * @Groups({"user.right.module.ref"})
  42.      */
  43.     private $user_right_module;
  44.     /**
  45.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="userRights")
  46.      * @ORM\JoinColumn(onDelete="CASCADE")
  47.      */
  48.     private $user;
  49.     /**
  50.      * @ORM\Column(type="boolean", nullable=true)
  51.      * @Groups({"user.right.core"})
  52.      */
  53.     private $can_read;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity=UserRightsModuleSectionRights::class, mappedBy="userRights", orphanRemoval=true, cascade={"persist"})
  56.      * @Groups({"user.right.module.section.rights"})
  57.      */
  58.     private $user_rights_module_section_rights;
  59.     public function __construct()
  60.     {
  61.         $this->user_rights_module_section_rights = new ArrayCollection();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function isCanInsert(): ?bool
  68.     {
  69.         return $this->can_insert;
  70.     }
  71.     public function setCanInsert(?bool $can_insert): self
  72.     {
  73.         $this->can_insert $can_insert;
  74.         return $this;
  75.     }
  76.     public function isCanEdit(): ?bool
  77.     {
  78.         return $this->can_edit;
  79.     }
  80.     public function setCanEdit(?bool $can_edit): self
  81.     {
  82.         $this->can_edit $can_edit;
  83.         return $this;
  84.     }
  85.     public function isCanDelete(): ?bool
  86.     {
  87.         return $this->can_delete;
  88.     }
  89.     public function setCanDelete(?bool $can_delete): self
  90.     {
  91.         $this->can_delete $can_delete;
  92.         return $this;
  93.     }
  94.     public function getUserRightModule(): ?UserRightModules
  95.     {
  96.         return $this->user_right_module;
  97.     }
  98.     public function setUserRightModule(?UserRightModules $user_right_module): self
  99.     {
  100.         $this->user_right_module $user_right_module;
  101.         return $this;
  102.     }
  103.     public function getUser(): ?User
  104.     {
  105.         return $this->user;
  106.     }
  107.     public function setUser(?User $user): self
  108.     {
  109.         $this->user $user;
  110.         return $this;
  111.     }
  112.     public function isCanRead(): ?bool
  113.     {
  114.         return $this->can_read;
  115.     }
  116.     public function setCanRead(?bool $can_read): self
  117.     {
  118.         $this->can_read $can_read;
  119.         return $this;
  120.     }
  121.     /**
  122.      * @return Collection<int, UserRightsModuleSectionRights>
  123.      */
  124.     public function getUserRightsModuleSectionRights(): Collection
  125.     {
  126.         return $this->user_rights_module_section_rights;
  127.     }
  128.     public function addUserRightsModuleSectionRight(UserRightsModuleSectionRights $userRightsModuleSectionRight): self
  129.     {
  130.         if (!$this->user_rights_module_section_rights->contains($userRightsModuleSectionRight)) {
  131.             $this->user_rights_module_section_rights[] = $userRightsModuleSectionRight;
  132.             $userRightsModuleSectionRight->setUserRights($this);
  133.         }
  134.         return $this;
  135.     }
  136.     public function removeUserRightsModuleSectionRight(UserRightsModuleSectionRights $userRightsModuleSectionRight): self
  137.     {
  138.         if ($this->user_rights_module_section_rights->removeElement($userRightsModuleSectionRight)) {
  139.             // set the owning side to null (unless already changed)
  140.             if ($userRightsModuleSectionRight->getUserRights() === $this) {
  141.                 $userRightsModuleSectionRight->setUserRights(null);
  142.             }
  143.         }
  144.         return $this;
  145.     }
  146. }