DunglasActionBundle icon indicating copy to clipboard operation
DunglasActionBundle copied to clipboard

[DX] Ease rounting generation by refering to routes by FQCN

Open backbone87 opened this issue 7 years ago • 0 comments

Insteadof $urlGenerator->generate('long_route_name_possibly_autogenerated', $params) maybe its possible to provide something like:

  • $urlGenerator->generate(MyAction::class, $params)
  • $urlGenerator[MyAction::class]($params)
  • $myAction->route($params)

Possible implementation strategies:

  • Decorate route loader to register 2 routes (one named with autogenerated name, one with FQCN as route name) for __invokeable controllers
  • Decorate UrlGenerator to generate route name from args that match a FQCN (if($classLoader->exists($routeName)) $routeName = $this->getDefaultRouteName($routeName);)
  • Keep a map in UrlGenerator to map route names (if($this->routeMap[$routeName]) $routeName = $this->routeMap[$routeName];)

WDYT?

backbone87 avatar Apr 09 '17 13:04 backbone87