controller-events Behavior/Event for CController to raise&handle 4 events: beforeAction(), afterAction(), beforeRender(), afterRender().

EControllerBehavior is a behavior that can handle controller events:

  • beforeAction
  • afterAction
  • beforeRender
  • afterRender

Your controller should extend EController. You create a behavior by extending EControllerBehavior and implement one of above listed methods. Inside a handler you have $event instance, which has following properties:

  • in beforeRender: $event->view.
  • in afterRender: $event->view and $event->output.
  • in beforeAction: $event->action.
  • in afterAction: $event->action.

Also, in beforeAction and beforeRender you can set $event->isValid property to allow or deny corresponding processing.

Also, it supports actions inside behaviors.


// main.php
	'import' => array('ext.controller-events.*'),
// CrudController.php
class CrudController extends EControllerBehavior {
	public function beforeAction(EControllerEvent $event) {
		if (rand(0, 1))
			$event->isValid = false;

Resources ΒΆ

1 0
Yii Version: 1.1
License: Apache-2.0
Category: Others
Developed by: wapmorgan
Created on: Apr 5, 2014
Last updated: 9 years ago


show all

Related Extensions