Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

The 'view' events not fired

Hello, I am using PhalconPHP v.1.3.2 I am trying to attach a listener to some of the 'view' events. The code I use is correct as it works fine when testing with any of the 'dispatcher' events. I found that there are only 'dispatcher' events fired. Does someone knows a way to display all the fired events or maybe a way to enable the view events?

Thanks a lot!


Just attach an events manager as you probably did with 'dispatcher' events:


$di->set('view', function() {

    //Create an events manager
    $eventsManager = new Phalcon\Events\Manager();

    //Attach a listener for type "view"
    $eventsManager->attach("view", function($event, $view) {
        file_put_contents('debug.txt', $event->getType() . ' - ' . $view->getActiveRenderPath() . PHP_EOL);

    $view = new \Phalcon\Mvc\View();

    //Bind the eventsManager to the view component

    return $view;

}, true);

Thanks a lot!

I forgot to add "$view->setEventsManager($eventsManager);"