1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| class Module
{
public function onBootstrap(MvcEvent $e)
{
$e->getApplication()->getServiceManager()->get('translator');
$eventManager = $e->getApplication()->getEventManager();
$this->initAcls($e);
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
public function initAcls($e)
{
$app = $e->getParam('application');
$app->getEventManager()->attach('route', array($this, 'checkAcls'), -100);
}
/**
*
* @param Zend\Mvc\MvcEvent $e
*/
public function checkAcls($e)
{
$routeMatch = $e->getRouteMatch();
if (!$routeMatch) {
return;
}
$controller = $routeMatch->getParam('controller', false);
if ($controller != 'Application\Controller\Admin') {
return;
}
$auth = new \Application\Service\AuthenticationService();
if ($auth->hasIdentity()) {
return;
}
// redirection vers la route 'login'
// comment faire ?
$router = $e->getRouter();
var_dump($router);
} |
Partager