Documentation on Component Event lacking


I am new to Yii (but not PHP or programming) and I found overall Yii documentation pretty good.

However the “Component Event” section in ‘Component’ chapter of Yii Guide is lacking overall explanation of how things flow and how actions are attached to events:

I found a pretty good explanation of the component events here:

Could you take some of the ideas that show how the event flows (with examples?) and add them to the guide’s page on component events?

Based on the second link I think this would help to note as an example in the Yii Guide (or as a page comment):

To invoke action ‘hello’ when a new user is created we define an event ‘onNewUser’ and attach it to the ‘hello’ action:

i) define the event:

public function onNewUser($event)


    $this->raiseEvent('onNewUser', $event);    //raises the event


ii) define actions executed upon event by defining a handler (one or more):

public function hello($event)


    $user = $event->sender;

    var_dump($user->firstname, $user->lastname);


iii) attach event to action(s):

$model->onNewUser = array($this, 'hello'); 

or as an anonymous function:

$model->onNewUser = function($event) {    

  $this->raiseEvent('onNewUser', $event);    //raises the event


iv) trigger event:

$event = new CModelEvent($this);


Thank you,


[color="#008000"]NOTE: moved to proper section (Feature request instead of General Discussion for Yii 1.1.x)[/color]