Passing variables/values to an event handler

This seems like it should be easy but I can’t figure it out. I just want to pass some contextual values to an event handler. I tried initiating CEvent as an object w/ my parameters in it, but that didn’t work:




$e = new CEvent(

	(object)array(

		'class'  => $this,

		'user'   => $user,

		'amount' => $amount

	)

);

			

Yii::app()->myController->onPurchase($e);

If I create the CEvent with simply ‘$this’ as an argument to the contructor, it works as expected. When I try the above, the event handler never gets called. No errors in the various logs either.

Thanks

The cleanest way might be to create your own event class. See the implementation of descendants of CEvent like CErrorEvent, CExceptionEvent, … They all add additional properties to store context data of the event.