我的错误页面在执行期间从未遇到以下代码。
理解DesignHandler在这里并不重要,但重要的是当发生错误时它会正确地路由到错误页面但从不会碰到这段代码。
namespace Application;
class Module
{
public function onBootstrap(MvcEvent $e)
{
$events = $e->getApplication()->getEventManager();
$sharedEvents = $events->getSharedManager();
$sharedEvents->attach(__NAMESPACE__, 'dispatch', function($e) {
$designHandler = Pluto::app()->getDesignHandler();
$designHandler->pump($e);
}, 20);
}
}
OR(我试过onbootstrap和init)
namespace Application;
class Module
{
public function init(\Zend\ModuleManager\ModuleManager $manager)
{
$events = $manager->getEventManager();
$sharedEvents = $events->getSharedManager();
$sharedEvents->attach(__NAMESPACE__, 'dispatch', function($e) {
$designHandler = Pluto::app()->getDesignHandler();
$designHandler->pump($e);
}, 20);
}
}
我不清楚如何解决这个问题。 我想当错误发生时,它会短路并且此代码永远不会受到影响
更新
我也用两段代码尝试了这个并没有成功:
$sharedEvents->attach(__NAMESPACE__, 'dispatch.error', function($e) {
$designHandler = Pluto::app()->getDesignHandler();
$designHandler->pump($e);
}, 20);