In Drupal, we have two common patterns called "info hooks" and "alter
hooks". In a nutshell, we call a hook (think procedural events) that
all modules may implement, where each module returns a big keyed nested
array of data, usually definition data of some sort. That definition
array is then combined, and passed to another "alter" hook by reference
so that other modules may poke at, examine, and modify the array.
I am pushing to switch many of our hooks over to Symfony Events, as we
are already using events in a number of areas now and they are
inherently more testable. However, this "info and alter" pattern is one
we need to retain in some form. As an example, we are now using Symfony
Route objects defined by modules. Modules will be able to define routes
using YAML, but once we build that RouteCollection we still need to pass
those routes to other modules for tweaking. We also need an event to
allow modules to define routes at runtime (well, at rebuild time anyway)
based on user configuration.
Does a pattern like this exist in the Symfony universe? Is there some
existing best practice we can leverage and/or model on that would be
familiar to Symfonians, or at the very least some known pitfalls or
stupid ideas for us to avoid?
My first cut attempt at that is available in this patch:
http://drupal.org/node/1801570#comment-6691680
One of the other reviewers commented that passing an empty route
collection to an event to get filled seems weird, and I agree, but I am
not sure what the more proper way of doing that is. Hence the question.
We do enough of this "info and alter" logic that it would be great to
generalize to make it easier and more consistent using Events and
objects, the way we have it fairly well nailed down for hooks and
arrays. I am seeking advise on the best way to do that.
Thoughts?
--Larry Garfield
--
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