Maybe I'm trying to use the EventDispatcher for something it's not
meant for...
I wanted to use it so that when a particular method is invoked, it
would do something like:
$eventDispatcher->addListener('doView', function(View $view) {
...
});
...
$eventDispatcher->dispatch('doView', $view);
View is an object in our proprietary MVC framework - we're not using
Symfony2 full-stack; we're just looking at using some of the
components for now.
Now of course this doesn't work because the listener always takes a
single Event argument.
And I've implemented something like what I illustrated above by
subclassing Event to create a new EventWithArguments class that holds
an array of arguments and subclassing EventDispatcher to have a
dispatchWithArguments method that creates a new
EventWithArguments(func_get_args()) and then does $this->dispatch with
that.
This works but seems a bit kludgey.
If this were a use case that people think is important, then maybe we
could find a way to have EventDispatcher handle it nicely (and I'd be
willing to send a pull request with my stuff).
On the other hand, maybe I'm pushing a boulder uphill and maybe what I
want is not an event dispatcher (maybe more of a signal and slot
system?) Maybe there is a better tool or design pattern for my use
case?
Cheers,
Marc
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en