Passing Event Parameters By Reference

I insert an event in my component’s method that will use two variables declared within the method and work with them, like this:




$a=new CEvent($this,array('var1'=>&$var1,'var2'=>&$var2));

$this->raiseEvent('onModifyVar',$a);




I want to be able to add event handlers that will take the two variables given and modify them to something else and send them back, like this:




function 'add2prop'($event){

$event->params['var1'].='something';

$event->params['var2'].='somethingelse';

}

$component->onModifyVar='add2prop';




Will my var1 and var2 change?

You can pass variable references inside of an array

and you can pass the array to the object with the references intact

and a function/method can take the object, then take its array,

and use the variable references in the array for manipulation.