how to set route and dispatcher when i use security plugin and multi language support

Dear, thanks for this project, it help me a lot.

But i have a question, in my project , i use Security plugin for acl, the dispatcher i use as follows:

in public/index.php

$di->set('dispatcher', function() use ($di) {

$eventsManager = $di->getShared('eventsManager');

$security = new Security($di);

/*
 * We listen for events in the dispatcher using the Security plugin
*/ 
$eventsManager->attach('dispatch', $security);

$dispatcher = new Phalcon\Mvc\Dispatcher();
$dispatcher->setEventsManager($eventsManager);

return $dispatcher;
});

in Security.php

public function beforeDispatch(Event $event, Dispatcher $dispatcher) {

$auth = $this->session->get('auth');
if (!$auth){
    $role = 'Guests';
} else {
    $role = 'Users';
}

$controller = $dispatcher->getControllerName();
$action = $dispatcher->getActionName();

$acl = $this->getAcl();

$allowed = $acl->isAllowed($role, $controller, $action);

if ($allowed != Acl::ALLOW) {
// $this->flash->error("You don't have access to this module");
$dispatcher->forward(
array(
'controller' => 'index',
'action' => 'index'
)
);
return false;
}

}

but it did not show the menu and views, and it returned " 500, Internal Server Error "

my route is: $router = new Phalcon\Mvc\Router();

$router->add("/set-language/{language:[a-z]+}", array(
    'controller' => 'index',
    'action' => 'setLanguage'
));

please help me , thanks!



986

i can't do it success too. it's very hard !~

thanks help