Reputation: 1235
How to attach shared event manager to a specific route , for example zfcadmin route I want to do this in my "Base" Module not in zfcadmin module , I tried below code but it didn't work :
// if admin
$em->attach('zfcadmin', 'route', function ($e) {
// Do somethings in admin pages
},100) ;
Upvotes: 2
Views: 238
Reputation: 5095
I'm not sure what you're trying to accomplish (maybe elaborate), but to check if a specific route is being matched you could listen for the dispatch event and take action. I.e.:
$eventManager = $e->getApplication()->getEventManager();
$eventManager->attach(MvcEvent::EVENT_DISPATCH, function($e) {
echo $e->getRouteMatch()->getMatchedRouteName();
}, 100);
Upvotes: 1