Hi, I got the bug very close to this https://github.com/phalcon/cphalcon/issues/1874
But the dispatcher ignores all events attached to it in case when annotations are user for roiting. If I use default routing system dispatcher fires all events that I attached to it.
$di->set(
'dispatcher',
function () use ($di) {
$eventsManager = $di->getShared('eventsManager');
/**
* Handle exceptions and not-found exceptions using NotFoundPlugin
*/
$eventsManager->attach('dispatch:beforeException', new \APP\NotFoundPlugin);
$dispatcher = new Phalcon\Mvc\Dispatcher();
//Bind the EventsManager to the Dispatcher
$dispatcher->setEventsManager($eventsManager);
$dispatcher->setDefaultNamespace('APP\\Frontend\\Controllers');
return $dispatcher;
}
);
<?php
namespace APP\Frontend;
use APP\Acl\Gate;
class Module
{
public function registerAutoloaders()
{
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(array(
'APP\Frontend\Controllers' => realpath(__DIR__ . '/../../modules/frontend/controllers/'),
//'APP\Frontend\Controllers' => realpath(__DIR__ . '/../../modules/frontend/controllers/'),
'APP\Models' => '../app/models/',
));
$loader->register();
}
/**
* Register the services here to make them general or register in the ModuleDefinition to make them module-specific
*/
public function registerServices($di)
{
$dispatcher = $di->get('dispatcher');
$eventManager = new \Phalcon\Events\Manager();
$eventManager->attach('dispatch', new Gate());
$eventManager->attach("view:notFoundView", function($event, $view) {
throw new \Exception($view->getActiveRenderPath());
});
$dispatcher->setEventsManager($eventManager);
$dispatcher->setDefaultNamespace("APP\\Frontend\\Controllers\\");
$di->get('view')->setViewsDir(realpath(__DIR__ . '/../../modules/frontend/views/'.$di->get('siteLayout')));
}
}
These two events not fires at all.
Do I need 'tell' to dispatcher that he have to use these events in case when I use Annotations for Route?
Thanks