"beforeExecuteRoute" as Controller method are always executed before event listener method.
<?php
class SomeListener
{
public function beforeExecuteRoute() {
echo __METHOD__, '<br/>';
}
}
class PostsController extends \Phalcon\Mvc\Controller
{
public function beforeExecuteRoute() {
echo __METHOD__, '<br/>';
}
public function initialize() {
echo __METHOD__, '<br/>';
}
public function indexAction(){}
}
$di = new Phalcon\DI\FactoryDefault;
$eventsManager = $di->get('eventsManager');
$eventsManager->attach('dispatch', new SomeListener);
$dispatcher = new Phalcon\Mvc\Dispatcher;
$dispatcher->setDI($di);
$dispatcher->setControllerName('posts');
$dispatcher->setEventsManager($eventsManager);
$dispatcher->dispatch();
// PostsController::initialize
// PostsController::beforeExecuteRoute
// SomeListener::beforeExecuteRoute
Is it possible to execute listener method before controller method? i.e.: PostsController::initialize SomeListener::beforeExecuteRoute PostsController::beforeExecuteRoute