src/Entity/System/Profile.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass="App\Repository\System\ProfileRepository")
  7.  *
  8.  * @ORM\Table(name="ps_profile")
  9.  */
  10. class Profile
  11. {
  12.     public const ROOT_ID 1;
  13.     public const SUPPORT_ID 12;
  14.     public const TECH_SUPPORT_ID 25;
  15.     /** @var int
  16.      * @ORM\Id()
  17.      *
  18.      * @ORM\GeneratedValue()
  19.      *
  20.      * @ORM\Column(type="integer", name="id_profile")
  21.      */
  22.     private $id;
  23.     /** @var string
  24.      * @ORM\Column(type="string", length=25)
  25.      */
  26.     private $name;
  27.     /**
  28.      * @var Role[]|ArrayCollection
  29.      *
  30.      * @ORM\ManyToMany(targetEntity="App\Entity\System\Role", inversedBy="profiles")
  31.      *
  32.      * @ORM\JoinTable(name="ps_profile_role",
  33.      *  joinColumns={@ORM\JoinColumn(name="id_profile", referencedColumnName="id_profile")},
  34.      *     inverseJoinColumns={@ORM\JoinColumn(name="id_role", referencedColumnName="id_role")}
  35.      * )
  36.      */
  37.     private $roles;
  38.     public function __construct()
  39.     {
  40.         $this->roles = new ArrayCollection();
  41.     }
  42.     /**
  43.      * @return int
  44.      */
  45.     public function getId(): int
  46.     {
  47.         return $this->id;
  48.     }
  49.     /**
  50.      * @param int $id
  51.      *
  52.      * @return Profile
  53.      */
  54.     public function setId(int $id): Profile
  55.     {
  56.         $this->id $id;
  57.         return $this;
  58.     }
  59.     /**
  60.      * @return string
  61.      */
  62.     public function getName(): string
  63.     {
  64.         return $this->name;
  65.     }
  66.     /**
  67.      * @param string $name
  68.      *
  69.      * @return Profile
  70.      */
  71.     public function setName(string $name): Profile
  72.     {
  73.         $this->name $name;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return ArrayCollection|Role[]
  78.      */
  79.     public function getRoles()
  80.     {
  81.         return $this->roles;
  82.     }
  83.     /**
  84.      * @param ArrayCollection|Role[] $roles
  85.      *
  86.      * @return Profile
  87.      */
  88.     public function setRoles(ArrayCollection $roles): Profile
  89.     {
  90.         $this->roles $roles;
  91.         return $this;
  92.     }
  93.     public function addRole(Role $role): self
  94.     {
  95.         if (!$this->roles->contains($role)) {
  96.             $this->roles[] = $role;
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeRole(Role $role): self
  101.     {
  102.         if ($this->roles->contains($role)) {
  103.             $this->roles->removeElement($role);
  104.         }
  105.         return $this;
  106.     }
  107. }