Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Orm 登录时BjyAuthorize未检测到角色_Orm_Doctrine_Zend Framework2_Zfcuser_Bjyauthorize - Fatal编程技术网

Orm 登录时BjyAuthorize未检测到角色

Orm 登录时BjyAuthorize未检测到角色,orm,doctrine,zend-framework2,zfcuser,bjyauthorize,Orm,Doctrine,Zend Framework2,Zfcuser,Bjyauthorize,我与ZF2、ORM和BjyAuthorize合作 问题是,当我登录到方法getRoles时,标识返回空 class User implements UserInterface, ProviderInterface{ /** * @var \Doctrine\Common\Collections\Collection * * @ORM\ManyToMany(targetEntity="Application\Entity\Role", inversedBy="use

我与ZF2、ORM和BjyAuthorize合作

问题是,当我登录到方法getRoles时,标识返回空

class User implements UserInterface, ProviderInterface{

/**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\ManyToMany(targetEntity="Application\Entity\Role", inversedBy="user")
     * @ORM\JoinTable(name="user_role_linker",
     *   joinColumns={
     *     @ORM\JoinColumn(name="user_id", referencedColumnName="user_id")
     *   },
     *   inverseJoinColumns={
     *     @ORM\JoinColumn(name="role_id", referencedColumnName="id")
     *   }
     * )
     */
    protected $roles;

    public function __construct() {
        $this->roles = new \Doctrine\Common\Collections\ArrayCollection();
    }

 public function addRole(\Application\Entity\Role $role) {
        $this->roles[] = $role;

        return $this;
    }

    /**
     * Remove role
     *
     * @param \Application\Entity\Role $role
     */
    public function removeRole(\Application\Entity\Role $role) {
        $this->roles->removeElement($role);
    }

    /**
     * Get role
     *
     * @return \Doctrine\Common\Collections\Collection 
     */

    public function getRoles() {
        return $this->roles->getValues();
    }
}
另一方面,如果我在控制器中获取实体并使用getRoles,那么我就可以毫无问题地获取值

你能告诉我哪一个可能是问题吗

这是我的zfc用户信息:

<?php
return array(
    'doctrine' => array(
        'driver' => array(
            // overriding zfc-user-doctrine-orm's config
            'zfcuser_entity' => array(
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'paths' => 'module\Application\src\Application\Entity',
            ),

            'orm_default' => array(
                'drivers' => array(
                    'Application' => 'zfcuser_entity',
                ),
            ),
        ),
    ),

    'zfcuser' => array(
        // telling ZfcUser to use our own class
        'user_entity_class'       => '\Application\Entity\User',
        // telling ZfcUserDoctrineORM to skip the entities it defines
        'enable_default_entities' => false,
    ),

    '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.entitymanager.orm_default',
                'role_entity_class' => 'Application\Entity\Role',
             ),
        ),
    ),
);

您是否在“角色”表中定义了角色,并在用户角色链接器表中定义了用户ID roleid