Le 08/11/2012 22:31, Larry Garfield a écrit :
Yep, that's exactly right, Ryan. :-) (We'll make a Drupal dev out of you yet...)

I agree that many "tell me about yourself" operations belong in the DIC, now that we have that, but not all can go there. For instance, many routes will be based off of user configuration, by design, and those can't be regenerated from the DIC in a cleanly injected fashion (as far as I'm aware, anyway). (Besides, putting Routes into the DIC seems even weirder.)

The question was "is there a better or more Symfonic way to do it than a double event"? It looks like the answer is "eh, not really". So, we'll stick with that for now until someone comes up with something better. :-)

--Larry Garfield

Well, your 'info' event (which is a confusing name IMO as the event is not informing us) would use an Event object exposing only an adder (well, it could have a few getters allowing to access the Request object for instance), and then each listener could register its routes:

$event->addRoutes($routes);

This would be similar to your 'info' hook, except it is not using the return value. It is a good fit for an event too (depending of the place in the code of course as events may not be the best way everywhere) By the way, a compatibility layer is easy to implement (assuming you are able to convert the old return value to routes):

class LegacyRoutingHookListener
{
    public function onRouteInfo(RouteInfoEvent $event)
    {
        $legacyHooks = //... get an array of legacy info hook callables

$args = // ... build the array of arguments needed for the legacy hooks if any

        foreach ($legacyHooks as $hook) {
            $legacyRoutes = call_user_func_array($hook, $args);

            $routes = $this->convertLegacyRoutes($legacyRoutes);

            $event->addRoutes($routes);
        }
    }
}

--
Christophe | Stof

--
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 symfony-devs@googlegroups.com
To unsubscribe from this group, send email to
symfony-devs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to