src/Entity/AccessRoles.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AccessRolesRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use phpDocumentor\Reflection\Types\This;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. /**
  10.  * @ORM\Entity(repositoryClass=AccessRolesRepository::class)
  11.  */
  12. class AccessRoles
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      * @Groups({"access.role.core", "user.manage", "user.base"})
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=64)
  23.      * @Groups({"access.role.core", "user.manage", "role.base", "user.base"})
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\Column(type="integer")
  28.      * @Groups({"access.role.core", "user.manage", "role.base", "user.base"})
  29.      */
  30.     private $level;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity=AccessTypes::class, inversedBy="accessRoles")
  33.      * @ORM\JoinColumn(nullable=false)
  34.      * @Groups({"access.role.type.ref", "role.base"})
  35.      */
  36.     private $access_type;
  37.     /**
  38.      * @ORM\ManyToMany(targetEntity=User::class, mappedBy="user_accessed_roles")
  39.      */
  40.     private $users;
  41.     /**
  42.      * @ORM\ManyToMany(targetEntity=Worker::class, mappedBy="worker_accessed_roles")
  43.      */
  44.     private $workers;
  45.     /**
  46.      * @Groups({"user.manage", "role.base"})
  47.      * @ORM\Column(type="string", nullable=true)
  48.     */
  49.     private string $description;
  50.     /**
  51.      * @ORM\Column("selectable", nullable=true)
  52.      * @Groups({"user.manage", "role.base"})
  53.     */
  54.     private $selectable;
  55.     public function getSelectable(): ?bool {
  56.         return $this->selectable;
  57.     }
  58.     public function getDescription(): string
  59.     {
  60.         return $this->description;
  61.     }
  62.     public function setDescription(string $description): self
  63.     {
  64.         $this->description $description;
  65.         return $this;
  66.     }
  67.     public function __construct()
  68.     {
  69.         $this->users = new ArrayCollection();
  70.         $this->workers = new ArrayCollection();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getName(): ?string
  77.     {
  78.         return $this->name;
  79.     }
  80.     public function setName(string $name): self
  81.     {
  82.         $this->name $name;
  83.         return $this;
  84.     }
  85.     public function getLevel(): ?int
  86.     {
  87.         return $this->level;
  88.     }
  89.     public function setLevel(int $level): self
  90.     {
  91.         $this->level $level;
  92.         return $this;
  93.     }
  94.     public function getAccessType(): ?AccessTypes
  95.     {
  96.         return $this->access_type;
  97.     }
  98.     public function setAccessType(?AccessTypes $access_type): self
  99.     {
  100.         $this->access_type $access_type;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, User>
  105.      */
  106.     public function getUsers(): Collection
  107.     {
  108.         return $this->users;
  109.     }
  110.     public function addUser(User $user): self
  111.     {
  112.         if (!$this->users->contains($user)) {
  113.             $this->users[] = $user;
  114.             $user->addUserAccessedRole($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removeUser(User $user): self
  119.     {
  120.         if ($this->users->removeElement($user)) {
  121.             $user->removeUserAccessedRole($this);
  122.         }
  123.         return $this;
  124.     }
  125.     /**
  126.      * @return Collection<int, Worker>
  127.      */
  128.     public function getWorkers(): Collection
  129.     {
  130.         return $this->workers;
  131.     }
  132.     public function addWorker(Worker $worker): self
  133.     {
  134.         if (!$this->workers->contains($worker)) {
  135.             $this->workers[] = $worker;
  136.             $worker->addWorkerAccessedRole($this);
  137.         }
  138.         return $this;
  139.     }
  140.     public function removeWorker(Worker $worker): self
  141.     {
  142.         if ($this->workers->removeElement($worker)) {
  143.             $worker->removeWorkerAccessedRole($this);
  144.         }
  145.         return $this;
  146.     }
  147. }