public function listPermissionsForRole($role, $includeOrphans = true)
    {
        if ($this->permissionRoles === false) {
            $this->permissionRoles = [];

            foreach ($this->listPermissions() as $permission) {
                if ($permission->roles) {
                    foreach ((array) $permission->roles as $_role) {
                        $this->permissionRoles[$_role][$permission->code] = 1;
                    }
                }
                else {
                    $this->permissionRoles['*'][$permission->code] = 1;
                }
            }
        }

        $result = $this->permissionRoles[$role] ?? [];

        if ($includeOrphans) {
            $result += $this->permissionRoles['*'] ?? [];
        }

        return $result;
    }
public function listPermissionsForRole($role, $includeOrphans = true)
    {
        if ($this->permissionRoles === false) {
            $this->permissionRoles = [];

            foreach ($this->listPermissions() as $permission) {
                if ($permission->roles) {
                    foreach ((array) $permission->roles as $_role) {
                        $this->permissionRoles[$_role][$permission->code] = 1;
                    }
                }
                else {
                    $this->permissionRoles['*'][$permission->code] = 1;
                }
            }
        }

        $result = $this->permissionRoles[$role] ?? [];

        if ($includeOrphans) {
            $result += $this->permissionRoles['*'] ?? [];
        }

        return $result;
    }
public function listPermissionsForRole ( $ role , $ includeOrphans = true ) { if ( $ this -> permissionRoles === false ) { $ this -> permissionRoles = [ ] ; foreach ( $ this -> listPermissions ( ) as $ permission ) { if ( $ permission -> roles ) { foreach ( ( array ) $ permission -> roles as $ _role ) { $ this -> permissionRoles [ $ _role ] [ $ permission -> code ] = 1 ; } } else { $ this -> permissionRoles [ '*' ] [ $ permission -> code ] = 1 ; } } } $ result = $ this -> permissionRoles [ $ role ] ?? [ ] ; if ( $ includeOrphans ) { $ result += $ this -> permissionRoles [ '*' ] ?? [ ] ; } return $ result ; }
Returns an array of registered permissions belonging to a given role code
@param string $role
@param bool $includeOrphans
@return array
Returns an array of registered permissions belonging to a given role code