我和zfcrbac有个问题,我搞不清楚。
我想我可能错过了一些配置上的东西,但我读了几遍文档,没有任何线索。
每当我试着用它的时候
“传递给ZfcRbac\Service\RoleService::__construct()的参数1必须是ZfcRbac\IdentityProviderInterface的实例,Zend\Authentication\AuthenticationService给定的实例”
我有过
'identity_provider' => 'AuthService',
AuthService是Zend\Authentication\AuthenticationService的别名
我把它配置成这样
'factories' => array(
'Auth\Model\AuthStorage' => function($sm){
return new \Auth\Model\AuthStorage('auth_user');
},
'AuthService' => function($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'user','username','password', 'md5(concat("' . $staticSalt . '" ,?,passwordSalt)) and active=1');
$authService = new AuthenticationService();
$authService->setAdapter($dbTableAuthAdapter);
$authService->setStorage($sm->get('Auth\Model\AuthStorage'));
return $authService;
},
),所以我不知道我错过了什么?
发布于 2014-03-24 15:49:48
正如在文档中所说的:rbac.global.php.dist#L28
identity_provider选项的服务名称必须返回一个实现ZfcRbac\Identity IdentityProviderInterface的实例。我们提供一个内置的使用AuthenticationService:rbac.global.php.dist#L31的内置程序。
我建议您保持默认状态。为了构造ZfcRbac\Identity\AuthenticationIdentityProvider,ZfcRbac从其工厂获取Zend\Authentication\AuthenticationService。因此,您实际上需要的是将配置中的AuthService替换为'Zend\Authentication\AuthenticationService‘。
https://stackoverflow.com/questions/22553015
复制相似问题