private function compileUserRoles()
    {
        if ($this->userRoles !== null) {
            return;
        }

        if (!$this->user) {
            $this->userRoles = [];

            return;
        }

        $roleList = [];
        $roleExpansion = [];

        /** @var Role $role */
        foreach ($this->roleProvider->getAllRoles() as $role) {
            $roleList[$role->getId()] = $role;
        }

        /** @var Role $userRole */
        $userRoles = $this->user->getRoles();
        if ($userRoles) {
            foreach ($userRoles as $userRole) {
                $roleExpansion[] = $userRole->getName();

                $parentRole = $userRole->getParent();
                while ($parentRole) {
                    $roleExpansion[] = $parentRole->getName();
                    $parentRole = $parentRole->getParent();
                }
            }
        }
        $this->userRoles = array_unique($roleExpansion);
    }
private function compileUserRoles()
    {
        if ($this->userRoles !== null) {
            return;
        }

        if (!$this->user) {
            $this->userRoles = [];

            return;
        }

        $roleList = [];
        $roleExpansion = [];

        /** @var Role $role */
        foreach ($this->roleProvider->getAllRoles() as $role) {
            $roleList[$role->getId()] = $role;
        }

        /** @var Role $userRole */
        $userRoles = $this->user->getRoles();
        if ($userRoles) {
            foreach ($userRoles as $userRole) {
                $roleExpansion[] = $userRole->getName();

                $parentRole = $userRole->getParent();
                while ($parentRole) {
                    $roleExpansion[] = $parentRole->getName();
                    $parentRole = $parentRole->getParent();
                }
            }
        }
        $this->userRoles = array_unique($roleExpansion);
    }
private function compileUserRoles ( ) { if ( $ this -> userRoles !== null ) { return ; } if ( ! $ this -> user ) { $ this -> userRoles = [ ] ; return ; } $ roleList = [ ] ; $ roleExpansion = [ ] ; /** @var Role $role */ foreach ( $ this -> roleProvider -> getAllRoles ( ) as $ role ) { $ roleList [ $ role -> getId ( ) ] = $ role ; } /** @var Role $userRole */ $ userRoles = $ this -> user -> getRoles ( ) ; if ( $ userRoles ) { foreach ( $ userRoles as $ userRole ) { $ roleExpansion [ ] = $ userRole -> getName ( ) ; $ parentRole = $ userRole -> getParent ( ) ; while ( $ parentRole ) { $ roleExpansion [ ] = $ parentRole -> getName ( ) ; $ parentRole = $ parentRole -> getParent ( ) ; } } } $ this -> userRoles = array_unique ( $ roleExpansion ) ; }
Flattens roles using the roleProvider, for quick lookup.
Flattens roles using the roleProvider for quick lookup .