public function getRoles()
    {
        if ($this->initialized === false) {
            $this->initialize();
        }

        if ($this->roles !== null) {
            return $this->roles;
        }

        $this->roles = ['Neos.Flow:Everybody' => $this->policyService->getRole('Neos.Flow:Everybody')];

        $authenticatedTokens = array_filter($this->getAuthenticationTokens(), function (TokenInterface $token) {
            return $token->isAuthenticated();
        });

        if (empty($authenticatedTokens)) {
            $this->roles['Neos.Flow:Anonymous'] = $this->policyService->getRole('Neos.Flow:Anonymous');
            return $this->roles;
        }

        $this->roles['Neos.Flow:AuthenticatedUser'] = $this->policyService->getRole('Neos.Flow:AuthenticatedUser');

        /** @var $token TokenInterface */
        foreach ($authenticatedTokens as $token) {
            $account = $token->getAccount();
            if ($account === null) {
                continue;
            }

            $this->roles = array_merge($this->roles, $this->collectRolesAndParentRolesFromAccount($account));
        }

        return $this->roles;
    }
public function getRoles()
    {
        if ($this->initialized === false) {
            $this->initialize();
        }

        if ($this->roles !== null) {
            return $this->roles;
        }

        $this->roles = ['Neos.Flow:Everybody' => $this->policyService->getRole('Neos.Flow:Everybody')];

        $authenticatedTokens = array_filter($this->getAuthenticationTokens(), function (TokenInterface $token) {
            return $token->isAuthenticated();
        });

        if (empty($authenticatedTokens)) {
            $this->roles['Neos.Flow:Anonymous'] = $this->policyService->getRole('Neos.Flow:Anonymous');
            return $this->roles;
        }

        $this->roles['Neos.Flow:AuthenticatedUser'] = $this->policyService->getRole('Neos.Flow:AuthenticatedUser');

        /** @var $token TokenInterface */
        foreach ($authenticatedTokens as $token) {
            $account = $token->getAccount();
            if ($account === null) {
                continue;
            }

            $this->roles = array_merge($this->roles, $this->collectRolesAndParentRolesFromAccount($account));
        }

        return $this->roles;
    }
public function getRoles ( ) { if ( $ this -> initialized === false ) { $ this -> initialize ( ) ; } if ( $ this -> roles !== null ) { return $ this -> roles ; } $ this -> roles = [ 'Neos.Flow:Everybody' => $ this -> policyService -> getRole ( 'Neos.Flow:Everybody' ) ] ; $ authenticatedTokens = array_filter ( $ this -> getAuthenticationTokens ( ) , function ( TokenInterface $ token ) { return $ token -> isAuthenticated ( ) ; } ) ; if ( empty ( $ authenticatedTokens ) ) { $ this -> roles [ 'Neos.Flow:Anonymous' ] = $ this -> policyService -> getRole ( 'Neos.Flow:Anonymous' ) ; return $ this -> roles ; } $ this -> roles [ 'Neos.Flow:AuthenticatedUser' ] = $ this -> policyService -> getRole ( 'Neos.Flow:AuthenticatedUser' ) ; /** @var $token TokenInterface */ foreach ( $ authenticatedTokens as $ token ) { $ account = $ token -> getAccount ( ) ; if ( $ account === null ) { continue ; } $ this -> roles = array_merge ( $ this -> roles , $ this -> collectRolesAndParentRolesFromAccount ( $ account ) ) ; } return $ this -> roles ; }
Returns the roles of all authenticated accounts, including inherited roles.

If no authenticated roles could be found the "Anonymous" role is returned.

The "Neos.Flow:Everybody" roles is always returned.

@return Role[]
@throws Exception
@throws Exception\NoSuchRoleException
Returns the roles of all authenticated accounts including inherited roles .