示例#1
0
文件: User.php 项目: blitzik/CMS
 /**
  * @return array
  */
 public function getRoles()
 {
     $rolesEntities = $this->roles->toArray();
     $roles = [];
     foreach ($rolesEntities as $role) {
         $roles[$role->getId()] = $role->getName();
     }
     return $roles;
 }
示例#2
0
文件: User.php 项目: Maksold/platform
 /**
  * {@inheritdoc}
  */
 public function getRoles()
 {
     $roles = $this->roles->toArray();
     /** @var Group $group */
     foreach ($this->groups as $group) {
         $roles = array_merge($roles, $group->getRoles());
     }
     return array_values(array_unique($roles));
 }
示例#3
0
文件: User.php 项目: j7mbo/aurex
 /**
  * @return Role[]
  *
  * @note Every user must *at least* have ROLE_USER as a role
  */
 public function getRoles()
 {
     return array_unique(array_merge($this->roles->toArray(), ['ROLE_USER']));
 }
示例#4
0
 /**
  * Returns the user's roles as an array of entities. The roles
  * owned by groups the user is a member are included by default.
  *
  * @param bool $areGroupsIncluded
  *
  * @return array[Role]
  */
 public function getEntityRoles($areGroupsIncluded = true)
 {
     $roles = array();
     if ($this->roles) {
         $roles = $this->roles->toArray();
     }
     if ($areGroupsIncluded) {
         foreach ($this->getGroups() as $group) {
             foreach ($group->getEntityRoles() as $role) {
                 if (!in_array($role, $roles)) {
                     $roles[] = $role;
                 }
             }
         }
     }
     return $roles;
 }
 /**
  * @return Role[]
  */
 public function getRoles()
 {
     return $this->roles->toArray();
 }
示例#6
0
 /**
  * @return Role[]
  */
 public function getAuthorizedRoles()
 {
     return $this->authorizedRoles->toArray();
 }