class Module {
public function onBootstrap($e) {
$em = $application->getEventManager();
$em->attach(MvcEvent::EVENT_DISPATCH, function($e) {
$controller = $e->getTarget();
if ($controller instanceof Controller\AdminController) {
$controller->layout('layout/layoutadmin.phtml');
} else {
$controller->layout('layout/layout.phtml');
}
});
}
}
并且不要忘记通过在模块配置文件中添加此配置来注册新控制器:
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController',
'Application\Controller\Admin' => 'Application\Controller\AdminController',
),
),