src/Entity/Role.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\RoleRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=RoleRepository::class)
  9.  */
  10. class Role extends BaseEntity
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\Column(type="text", nullable=true)
  24.      */
  25.     private $description;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $code;
  30.     /**
  31.      * @ORM\ManyToMany(targetEntity=User::class, mappedBy="userRoles")
  32.      */
  33.     private $users;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity=BPModelRole::class, mappedBy="role")
  36.      */
  37.     private $bPModelRoles;
  38.     /**
  39.      * @ORM\ManyToMany(targetEntity=Variable::class, inversedBy="roles")
  40.      */
  41.     private $variables;
  42.     public function __construct()
  43.     {
  44.         $this->variables = new ArrayCollection();
  45.         $this->users = new ArrayCollection();
  46.         $this->bPModelRoles = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getName(): ?string
  53.     {
  54.         return $this->name;
  55.     }
  56.     public function setName(string $name): self
  57.     {
  58.         $this->name $name;
  59.         return $this;
  60.     }
  61.     public function getDescription(): ?string
  62.     {
  63.         return $this->description;
  64.     }
  65.     public function setDescription(?string $description): self
  66.     {
  67.         $this->description $description;
  68.         return $this;
  69.     }
  70.     public function getCode(): ?string
  71.     {
  72.         return $this->code;
  73.     }
  74.     public function setCode(string $code): self
  75.     {
  76.         $this->code $code;
  77.         return $this;
  78.     }
  79.     /**
  80.      * @return Collection<int, User>
  81.      */
  82.     public function getUsers(): Collection
  83.     {
  84.         return $this->users;
  85.     }
  86.     public function addUser(User $user): self
  87.     {
  88.         if (!$this->users->contains($user)) {
  89.             $this->users[] = $user;
  90.             $user->addUserRole($this);
  91.         }
  92.         return $this;
  93.     }
  94.     public function removeUser(User $user): self
  95.     {
  96.         if ($this->users->removeElement($user)) {
  97.             $user->removeUserRole($this);
  98.         }
  99.         return $this;
  100.     }
  101.     /**
  102.      * @return Collection<int, BPModelRole>
  103.      */
  104.     public function getBPModelRoles(): Collection
  105.     {
  106.         return $this->bPModelRoles;
  107.     }
  108.     public function addBPModelRole(BPModelRole $bPModelRole): self
  109.     {
  110.         if (!$this->bPModelRoles->contains($bPModelRole)) {
  111.             $this->bPModelRoles[] = $bPModelRole;
  112.             $bPModelRole->setRole($this);
  113.         }
  114.         return $this;
  115.     }
  116.     public function removeBPModelRole(BPModelRole $bPModelRole): self
  117.     {
  118.         if ($this->bPModelRoles->removeElement($bPModelRole)) {
  119.             // set the owning side to null (unless already changed)
  120.             if ($bPModelRole->getRole() === $this) {
  121.                 $bPModelRole->setRole(null);
  122.             }
  123.         }
  124.         return $this;
  125.     }
  126.     /**
  127.      * @return Collection<int, Variable>
  128.      */
  129.     public function getVariables(): Collection
  130.     {
  131.         return $this->variables;
  132.     }
  133.     public function addVariable(Variable $variable): self
  134.     {
  135.         if (!$this->variables->contains($variable)) {
  136.             $this->variables[] = $variable;
  137.         }
  138.         return $this;
  139.     }
  140.     public function removeVariable(Variable $variable): self
  141.     {
  142.         $this->variables->removeElement($variable);
  143.         return $this;
  144.     }
  145. }