DunglasActionBundle
DunglasActionBundle copied to clipboard
[DX] Ease rounting generation by refering to routes by FQCN
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
__invoke
able 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?