2

In a runtime context, given I have a route object, e.g. from route name user.register, how do I find the path or routing.yml or other definer of the route?

Does Drupal or Symfony provide for this?

There's probably a better way to do what I want. The scenario I have is: a plugin manager is deciding which plugin to instantiate based on route context. For example, if module foo defines route foo.bar at path /foo/bar, the plugin manager will instantiate plugin foo_plugin. If module, zee defines route zee.bang at path /zee/bang, the plugin manager will instantiate zee_plugin

  • What exactly are you trying to achieve? This doesn't seem the real question for which you need an answer, as which module implements a route is normally not useful to write code for a module/theme. – kiamlaluno Nov 6 at 15:49
  • You're right, there's probably a better way to do what I want. The scenario I have is: a plugin manager is deciding which plugin to instantiate based on route context. For example, if module foo defines route foo.bar at path /foo/bar, the plugin manager will instantiate plugin foo_plugin. If module, zee defines route zee.bang at path /zee/bang, the plugin manager will instantiate zee_plugin – aaronbauman Nov 6 at 15:53
  • Edit the question to add what you just said. Don't forget to add an explicit, not broad, question too. Remember that best way is seen as subjective. – kiamlaluno Nov 6 at 16:25
  • 3
    The route object itself has no reference to the route name. This is for example why they needed to add a route name to OutboundRouteProcessor, see drupal.org/project/drupal/issues/2346283 – 4k4 Nov 6 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.