Passing paremters into event handler directly

I have been trying to use events feature. It realy helps to do many things easily.

I just wonder why Yii events feature does not allowing send parameters directly. There even exists ‘params’ field at CEvent class.

actualy task was to make payment handler which will raise onSuccess event, and system will execute needed actions. But payment manager should work with various of payment methods. Some payment methods do not completing imediatelly, they are completing after some time by payment provider and payment provider sending request to our side (paypal, 2co etc).

So, to handle this i needed to serialize and save event handlers to the database for next use.

But i noticed that the anonymous function will not be generated properly from saved serialized string because it saves only link to it. And link will exists while current script runing.

To have saving event abiltiy i needed to bypass using anonymous functions. So i needed to create function under some class and use following code:




    $obj->onSuccess = array($user,'doSomeActions');



this code allows save events to db:




public function beforeSave(){

	parent::beforeSave();

	

	foreach (array('onSuccess','onError') as $name){

		$events[$name] = $this->getEventHandlers($name);

	}

	

	$this->events = serialize($events);

	return true;

}



So here we came to base problem of this topic - event parameters.

Finally, i found way to save event handlers into database for next use, but still cant save event parameters.

It would be realy nice if event function under CComponent class will allow to pass paramters into it. for example by this way:




 $obj->onSuccess = array($user,'doSomeActions',$params); // thrid paramter will be used as parameter



and following change can be made at raiseEvent function:




list($object,$method,$params)=$handler;


........


else if(method_exists($object,$method))

$object->$method($event,$params);



In any case thank you for best framework.

[color=#222222][font=Arial, sans-serif][size=2]params[/size][/font][/color][color=#222222][font=Arial, sans-serif][size=2] property (available since v1.1.7)[/size][/font][/color]

[color=#222222][font=Arial, sans-serif][size=2]

[/size][/font][/color]

[font=“Arial, sans-serif”][size=“2”][color="#222222"]That’s the first thing that pops to mind. What version are you using?[/color][/size][/font]

i am using last version, 1.1.9

but params property can be initialized once actual event object generated. Exactly at onSuccess event:




public function onSuccess(){

	$event = new CModelEvent($this);

	$this->raiseEvent('onSuccess', $event);

}



in case if event handler takes from db, there is no way to know params than. thats is problem.