我有两个实体:User
和Member
来访问我的ZF2应用程序中的不同模块。
我有两种不同的登录表单来建立连接。
Member
专用模块的配置:
'doctrine' =>
[
'authenticationservice' =>
[
'platform' => true,
],
'authenticationstorage' =>
[
'platform' => true,
],
'authenticationadapter' =>
[
'platform' => true
],
'authentication' =>
[
'platform' =>
[
'storage' => 'Platform_Auth',
'objectManager' => EntityManager::class,
'identityClass' => Member::class,
'identityProperty' => 'login',
'credentialProperty' => 'password',
'credentialCallable' => function (Member $member, $password)
{
return ($member->getPassword() === md5($password));
}
],
]
],
User
专用模块
'doctrine' =>
[
'authenticationservice' =>
[
'admin' => true,
],
'authenticationstorage' =>
[
'admin' => true,
],
'authenticationadapter' =>
[
'admin' => true
],
'authentication' =>
[
'admin' =>
[
'storage' => 'Admin_Auth',
'objectManager' => EntityManager::class,
'identityClass' => User::class,
'identityProperty' => 'login',
'credentialProperty' => 'password',
'credentialCallable' => function (User $user, $password)
{
return ($user->getPassword() === md5($password));
}
]
]
],
如何使用2种不同配置的Doctrine身份验证?
有没有办法实现这个目标?
修改 我可以使用一个共享身份验证工厂和基于路由的扩展(平台/管理员)...但我不知道这是不是一个好主意......
edit2
配置存储时出现另一个错误:
“.... Zend \ ServiceManager \ ServiceManager :: get无法在...中为Admin_Auth获取或创建实例”
非常感谢任何帮助