4

I want to listen for Yii events like onBeginRequest and onEndRequest. I've tried the following but nothing happens :(

\Yii::app()->onBeginRequest = create_function('$event', 'die ("YO") ;');

and

craft()->attachEventHandler('onBeginRequest', array($this, 'dieyo'));

and

craft()->getEventHandlers('onBeginRequest')->add(array($this, 'dieyo'));

-

public function dieyo($event)
{
    craftdd($event);
}

Thanks in advance

1
  • Did some more testing "onEndRequest" works fine. So I guess onBeginRequest is a loader and/or timing issue? – pythic Aug 8 '14 at 14:49
2

Yii fires the onBeginRequest event before Craft has had a chance to do any of the plugin bootstrapping / initialization, which is why it's not firing in your plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.