Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Created December 25, 2013 03:49
Show Gist options
  • Save Ocramius/8120024 to your computer and use it in GitHub Desktop.
Save Ocramius/8120024 to your computer and use it in GitHub Desktop.
Module class to intercept route match results in a ZF2 application
<?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