- Tmp code allowing to override routes
This commit is contained in:
parent
959a182d16
commit
1f828eb022
|
@ -17,6 +17,8 @@ class Routing {
|
|||
|
||||
public ResponseInterface $response;
|
||||
|
||||
protected array $registeredRoutes;
|
||||
|
||||
public function __construct(
|
||||
public Router $router,
|
||||
public RouteFetcher $fetcher,
|
||||
|
@ -24,12 +26,20 @@ class Routing {
|
|||
) { }
|
||||
|
||||
public function registerRoute(ContainerInterface $container, string $urlBase) {
|
||||
$this->router->group(rtrim($urlBase, "/"), function (RouteGroup $route) use ($container) {
|
||||
foreach($this->fetcher->compile() as $attribute) {
|
||||
$this->registeredRoutes[$urlBase] ??= [];
|
||||
|
||||
$this->router->group(rtrim($urlBase, "/"), function (RouteGroup $route) use ($container, $urlBase) {
|
||||
foreach(array_reverse($this->fetcher->compile()) as $attribute) {
|
||||
$this->eventManager->execute(Event\RoutingCompileRoutes::class, $this, $attribute);
|
||||
|
||||
# Mapping every URLs from attributes in searched folders (Api, Controller, etc...)
|
||||
foreach((array) $attribute->method as $method) {
|
||||
if (! empty($this->registeredRoutes[$urlBase][$attribute->getRoute().$method])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->registeredRoutes[$urlBase][$attribute->getRoute().$method] = true;
|
||||
|
||||
$route->map(strtoupper($method), $attribute->getRoute(), function (ServerRequestInterface $request, array $arguments) use (
|
||||
$container, $route, $attribute
|
||||
) : ResponseInterface {
|
||||
|
|
Loading…
Reference in New Issue