Php 如何使用Zend Framework';s&x201C;BjyAuthorize”;获取记录的用户角色数组的步骤

Php 如何使用Zend Framework';s&x201C;BjyAuthorize”;获取记录的用户角色数组的步骤,php,zend-framework2,Php,Zend Framework2,这是获取记录的用户角色数组的方法吗?当我要求: $this->getServiceLocator()->get('BjyAuthorize\Provider\Identity\ProviderInterface')->getIdentityRoles() 我收到一系列的大目标。我喜欢接收ZendDeveloperTools工具栏中的数组 我用这个理论: 'bjyauthorize' => array( // Using the authentication id

这是获取记录的用户角色数组的方法吗?当我要求:

$this->getServiceLocator()->get('BjyAuthorize\Provider\Identity\ProviderInterface')->getIdentityRoles()
我收到一系列的大目标。我喜欢接收ZendDeveloperTools工具栏中的数组

我用这个理论:

'bjyauthorize' => array(
    // Using the authentication identity provider, which basically reads the roles from the auth service's identity
    'identity_provider' => 'BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider',
    'role_providers' => array(
        // using an object repository (entity repository) to load all roles into our ACL
        'BjyAuthorize\Provider\Role\ObjectRepositoryProvider' => array(
            'object_manager' => 'doctrine.entity_manager.orm_default',
            'role_entity_class' => 'Application\Entity\Role',
        ),
    ),
)

角色实体应实现Zend\Permissions\Acl\role\RoleInterface。此接口由一个方法getRoleId()组成,因此您可以在集合上foreach来构建RoleId数组。

我知道这一点,但我问的是,是否已经有直接数组响应的方法,或者我必须扩展某些方法,因为foreach每次都需要检查是否有角色,这并不好