Event Dispatcher - about events names

2 views
Skip to first unread message

OZ

unread,
Nov 23, 2010, 3:49:04 PM11/23/10
to Symfony Components
Hello.
It's my first letter and first experience of Google Group using. So,
sorry if i do something wrong.

I'm reading now "http://components.symfony-project.org/event-
dispatcher/trunk/book/01-Event-Dispatcher" (after
http://fabien.potencier.org/talk/19/decouple-your-code-for-reusability-ipc-2008),
and I have idea about the "Event" class.

What if add constants with names of events? For example,

class Event
{
const User_ChangeCulture="user.change_culture";
const Another_EventName="another.event_name_for_example";

protected $value = null;
....
}

then we can change code

$event = new sfEvent($this, 'user.change_culture', array('culture' =>
$culture)); //(it's example code from documentation page)

to

$event = new sfEvent($this, Event::User_ChangeCulture, array('culture'
=> $culture));

By this upgrade, we can use IDE code-tips (autocomplete, etc), and it
can decrease errors and typos frequency.

Sorry for my broken English, and excuse me, if this question was been
already asked.

Thank you very much for your code, for your lessons and examples.
Reply all
Reply to author
Forward
0 new messages