这是我的代码:
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));
}
}
}
使用它后,我得到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
. 我做错了什么