src/Entity/AccessRoles.php line 17

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