jjzjj

MvcEvent

全部标签

php - Zend 框架 2 : Set Layout using MvcEvent

我想使用mvc事件更改布局。我尝试了以下方法://$eventinstanceof\Zend\Mvc\MvcEvent$serviceManager=$event->getApplication()->getServiceManager();$controllerLoader=$serviceManager->get('ControllerLoader');$controllerLoader->addInitializer(function($controller){$controller->layout('layout/example');//ORTHIS$controller->g

php - ACL授权失败后ZF3重定向

我有一个带有ACL的新ZF3应用程序。现在我需要在未经授权的情况下重定向到错误页面(例如403)。我认为最好的方法是触发一个事件,然后捕获它,但我失败了...所有内容都在我的用户模块中,在Module.php(摘录)中:namespaceUser;useZend\Mvc\MvcEvent;useZend\Permissions\Acl\Acl;useZend\Stdlib\Response;useZend\View\Model\ViewModel;[...]classModuleimplementsConfigProviderInterface{[...]publicfunctiono

php - ZF2如何监听特定controller的dispatch事件

如何监听特定Controller的调度事件?目前,我执行以下操作:Module.phppublicfunctiononBootstrap(EventInterface$event){$application=$event->getApplication();$eventManager=$application->getEventManager();$serviceManager=$application->getServiceManager();$eventManager->attach($serviceManager->get('MyListener'));}MyListener.p