Created
December 25, 2013 03:49
-
-
Save Ocramius/8120024 to your computer and use it in GitHub Desktop.
Module class to intercept route match results in a ZF2 application
This file contains 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 | |
namespace My; | |
class Module | |
{ | |
public function onBootstrap(\Zend\EventManager\EventInterface $e) | |
{ | |
// event target is the application itself | |
$e->getTarget()->getEventManager()->attach( | |
\Zend\Mvc\MvcEvent::EVENT_ROUTE, // we want to listen to the "route" step of the application | |
function(\Zend\Mvc\MvcEvent $e) { | |
// this will just kill the application and dump the result of routing | |
die(var_dump($e->getRouteMatch())); | |
}, | |
-1000 // low priority is required, so that the listener is executed after routing (which is priority 1) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment