I would love to see some improvements on the event system. Adding events dynamically using behaviors is an interesting aspect. I can also remember I had some problems understanding yii’s event system when I looked at it the first time, so more room for improvements. I think part of that confusion was that I had to assign a callback to an existing method…
Don’t get me wrong: I prefer explicitly declared events over the raise(something) approach. I want the events I use to be documented, supported by my IDE and I want them to be validated. It’s only that assign-to-method, which I think caused confusion. But this is only event registration, only part of the whole, don’t want to focus on that right now…
What I would appreciate were some additional features like static events:
User::onRegistrationConfirmed = array( $this, 'sendWelcomeMessage' );
and inter-component events:
return $appConfig = array(
'connections' => array(
array( 'module.user', 'onUserRegistered', 'module.admin', 'queueForConfirmation' ),
),
);
Besides this, I think there should be more discussion about what events should be used for than about how they should be defined. I personally like to think of events as notifications. “Hey there! Something happened!”. That’s why I love Qt’s signals. Their single purpose is to notify. Without any knowledge (or interest) about who or what or if something is listening to them. They don’t have a return value. Nor do they check a “handled” flag (at least I don’t know of something like this).
Yii’s events are different. They are often used to provide extension points. “Hey there! Currently I’m in this state! Prepared me? Ok, I’m moving on! Hey there, me again! Now I’m in this state…”.
You see, these are two different things. The one is about notifications, the other about customizing behavior. Maybe only two use cases for one mechanism, but I wonder if maybe it shouldn’t be two separate ones.
Oh, about the inter-component events:
I posted a proof of concept implementation in an older thread about events.