Event not triggering correctly

Here is my code:

class Module
{
    public function onBootstrap(MvcEvent $e)
    {

       $app = $e->getParam('application');
       $app->getEventManager()->attach('pre.loadevents',array($this,'preLoadEvents'));
       $app->getEventManager()->attach('loadevents',array($this,'loadEvents'));
       $app->getEventManager()->attach('post.loadevents',array($this,'postLoadEvents'));
       $app->getEventManager()->trigger('loadevents',null,[]);
    }       

    public function preLoadEvents(MvcEvent $e)
    {

    }

    public function postLoadEvents(MvcEvent $e)
    {

    }

    public function loadEvents(MvcEvent $e)
    {

        $app = $e->getParam('application');
        $eventsConfig = yoda::config('module/application/events/event');
        foreach($eventsConfig as $event){
            if((int)$event->active===0)continue;
            $app->getEventManager()->attach($event->name,array($this,$event->method));
        }

    }
}

Upon using this I get Fatal error: Uncaught TypeError: Argument 1 passed to Application\Module::loadEvents() must be an instance of Zend\Mvc\MvcEvent, instance of Zend\EventManager\Event given. What am I doing incorrectly

Answers


You should have

public function loadEvents(\Zend\EventManager\Event $e)
{
   ...
}

instead of

public function loadEvents(MvcEvent $e)
{
   ...
}

because it is not a MVC event you are getting here.


Need Your Help

Border Radius Implementation for Windows Phone in Xamarin

xamarin xamarin.forms

Currenly, I'm using this as reference Border Radius for border radius but it seems like it's not working in my side. Does the Xamarin has a built in functionality for Border Radius Implementation?

In knockout.js an observable function is not updating

knockout.js

It's probably easiest to understand my question in reference to my jsFiddle