Created
August 29, 2012 19:54
-
-
Save weierophinney/3517979 to your computer and use it in GitHub Desktop.
Example of triggering another dispatch event in ZF2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Zend\Mvc\Router\RouteMatch; | |
// Listener on dispatch.error event | |
$listener = function ($e) { | |
$app = $e->getTarget(); | |
$events = $app->getEventManager(); | |
$event = clone $e; | |
$matches = new RouteMatch(array('controller' => 'Some\Controller\Alias')); | |
$event->setRouteMatch($matches); | |
$events->trigger('dispatch', $event); | |
// to be thorough, you should probably copy some of the logic of Zend\Mvc\DispatchListener | |
// to ensure you get similar behavior with regards to errors. | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment