From 7a587f62a6891905ee987ea993c3a0ca71640b78 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 30 Jun 2013 21:01:14 -0400 Subject: [PATCH] Added back the events for Controller. --- framework/yii/base/Controller.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/framework/yii/base/Controller.php b/framework/yii/base/Controller.php index 3ed6736..471fc63 100644 --- a/framework/yii/base/Controller.php +++ b/framework/yii/base/Controller.php @@ -18,6 +18,15 @@ use Yii; class Controller extends Component { /** + * @event ActionEvent an event raised right before executing a controller action. + * You may set [[ActionEvent::isValid]] to be false to cancel the action execution. + */ + const EVENT_BEFORE_ACTION = 'beforeAction'; + /** + * @event ActionEvent an event raised right after executing a controller action. + */ + const EVENT_AFTER_ACTION = 'afterAction'; + /** * @var string the ID of this controller */ public $id; @@ -192,7 +201,9 @@ class Controller extends Component */ public function beforeAction($action) { - return true; + $event = new ActionEvent($action); + $this->trigger(self::EVENT_BEFORE_ACTION, $event); + return $event->isValid; } /** @@ -203,6 +214,9 @@ class Controller extends Component */ public function afterAction($action, &$result) { + $event = new ActionEvent($action); + $event->result = & $result; + $this->trigger(self::EVENT_AFTER_ACTION, $event); } /**