Hi, I'm having a weird issue with implementing a beforeDispatch() method within my Security plugin in Zephir.

I first implemented the Security plugin as per the INVO example in Phalcon, including a beforeDispatch() method to check the application's ACL. In Module.php I set the Security plugin as handler for dispatch events. All this works fine.

Then I rewrote the Security plugin in Zephir. Now the beforeDispatch() method doesn't get called anymore. Even if I just put a simple log print message and return true, it doesn't get called. I see no output in any error log either and the web response is blank with an HTTP 200 code.

Strangely though, the following works:

  1. Write a Security.php class that derives from the Zephir class,
  2. In the PHP class implement a beforeDispatch() method that simply returns the result of the call to the parent class's beforeDispatch() method
  3. In Module.php make sure to use the PHP class instead of the Zephir class as dispatch event listener

My code is as follows:

Security.php

namespace Multiple\Core\Plugins;

use Phalcon\Events\Event,
    Phalcon\Mvc\Dispatcher;

class Security extends \MyZephir\Plugins\Security
{
    public function beforeDispatch(Event $event, Dispatcher $dispatcher)
    {

        return parent::beforeDispatch($event, $dispatcher);
    }
}

Security.zep

namespace MyZephir\Plugins;

class Security extends \Phalcon\Mvc\User\Plugin
{

    public function __construct(<\Phalcon\Di\FactoryDefault> dependencyInjector)
    {
        let this->_dependencyInjector = dependencyInjector;
    }


    public function beforeDispatch(<\Phalcon\Events\Event> event, <\Phalcon\Mvc\Dispatcher> dispatcher) -> bool
    {
        return true;  //<-- For simplicity just return true

    }

Module.php (make the PHP Security class as the event listener):

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

            $dispatcher = new \Phalcon\Mvc\Dispatcher();

            //Attach a event listener to the dispatcher
            $eventManager = new \Phalcon\Events\Manager();
            $eventManager->attach('dispatch', new \Multiple\Core\Plugins\Security($di));  //<-- This is the PHP class

            $dispatcher->setEventsManager($eventManager);
            $dispatcher->setDefaultNamespace("Multiple\Core\Controllers\\");
            return $dispatcher;
        });

In Module.php if the Security class name is changed to \MyZephir\Plugins\Security then the beforeDispatch() call does not work.

Any idea why the beforeDispatch() method in the Zephir class cannot be called directly?