Zend framework2 zf2 BJYA使用两种不同的基本布局授权Zfcuser
我有这个问题。在我的ZF2应用程序中,我使用byjauthorize和zfcuser管理登录系统,我有两种不同的基本布局。一个专用于登录页面,另一个专用于用户登录时的应用程序。这是module.config.php中应用程序模块中的代码:Zend framework2 zf2 BJYA使用两种不同的基本布局授权Zfcuser,zend-framework2,zfcuser,bjyauthorize,login-system,Zend Framework2,Zfcuser,Bjyauthorize,Login System,我有这个问题。在我的ZF2应用程序中,我使用byjauthorize和zfcuser管理登录系统,我有两种不同的基本布局。一个专用于登录页面,另一个专用于用户登录时的应用程序。这是module.config.php中应用程序模块中的代码: 'template_map' => array( 'layout/login_layout' => __DIR__ . '/../view/layout/login_layout.phtml',
'template_map' => array(
'layout/login_layout' => __DIR__ . '/../view/layout/login_layout.phtml',
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
现在总是在module.php中设置应用程序模块,我设置以下代码:
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
$application = $e->getTarget();
// Change default layout if user is logged
$sm = $application->getServiceManager();
$auth = $sm->get('zfcuser_auth_service');
if ($auth->hasIdentity()) {
$eventManager->attach("dispatch", function($e) {
$controller = $e->getTarget();
$s_matchedRoute = $e->getParam('route-match')->getMatchedRouteName();
if ($s_matchedRoute === 'zfcuser/login') {
$controller->layout('layout/login_layout');
} else {
$controller->layout('layout/layout');
}
});
/*
* Check Admin ACL with BjyAuthorize:
* use RedirectionStrategy (that redirects to ZfcUser's login route by default)
*/
$strategy = new RedirectionStrategy();
$strategy->setRedirectRoute('application/error');
$e->getTarget()->getEventManager()->attach($strategy);
} else {
$eventManager->attach("dispatch", function($e) {
$controller = $e->getTarget();
$controller->layout('layout/login_layout');
});
$strategy = new RedirectionStrategy();
$strategy->setRedirectRoute('zfcuser/login');
$e->getTarget()->getEventManager()->attach($strategy);
}
/**
* Format style login page
*/
$this->layoutFormLogin($eventManager);
// Setting function to handler error
set_error_handler(array('Application\Module','handlePhpErrors'));
}
但是当$auth->hasidenty为false时,重定向策略不会在zfcuser/login中重定向路由。米萨克在哪里?p、 s my application.config.php是这样的:
// 3rd part modules
'DoctrineModule',
'DoctrineORMModule',
'ZendDeveloperTools',
'ZfcBase',
'ZfcUser',
'ZfcUserDoctrineORM',
'BjyAuthorize',
'DOMPDFModule',
'WebinoImageThumb',
//My Module
'Application',