Yii2: More Events In Controller

I was working on a Behavior for which I had to listen to the Controller::render() method to be called. Even more, I had to distinguish between the type of render method called. Unfortunately, the Controller class only offers two events: EVENT_BEFORE_ACTION and EVENT_AFTER_ACTION. It would be nice if this list at least were extended with:

  • EVENT_BEFORE_RENDER

  • EVENT_BEFORE_RENDER_FILE

  • EVENT_BEFORE_RENDER_PARTIAL

  • EVENT_BEFORE_RENDER_AJAX

  • EVENT_AFTER_RENDER

  • EVENT_AFTER_RENDER_FILE

  • EVENT_AFTER_RENDER_PARTIAL

  • EVENT_AFTER_RENDER_AJAX

I know it is not likely new features will be added to current 2.0.0beta, but this is a minor adjustment with no disadvantages or compatibility issues. It would help me greatly, because I don’t want my components to extend from custom components, but I prefer the default components instead. :)

If anyone else is missing events, feel free to complement my list.

There are additional events in \yii\base\View and \yii\web\View.