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