- Added default values to routing

This commit is contained in:
Dave M. 2024-11-22 20:47:06 -05:00
parent 13d306aec9
commit f462fcc597
1 changed files with 1 additions and 9 deletions

View File

@ -27,21 +27,13 @@ class Routing {
) { } ) { }
public function registerRoute(ContainerInterface $container, string $urlBase) { public function registerRoute(ContainerInterface $container, string $urlBase) {
#$this->registeredRoutes ??= [];
$this->router->group(rtrim($urlBase, "/"), function (RouteGroup $route) use ($container) { $this->router->group(rtrim($urlBase, "/"), function (RouteGroup $route) use ($container) {
foreach($this->fetchRoutesAttributes() as $attribute) { foreach($this->fetchRoutesAttributes() as $attribute) {
$this->eventManager->execute(Event\RoutingCompileRoutes::class, $this, $attribute); $this->eventManager->execute(Event\RoutingCompileRoutes::class, $this, $attribute);
# Mapping every URLs from attributes in searched folders (Api, Controller, etc...) # Mapping every URLs from attributes in searched folders (Api, Controller, etc...)
foreach((array) $attribute->method as $method) { foreach((array) $attribute->method as $method) {
#if (! empty($this->registeredRoutes[$attribute->getRoute().$method])) { $route->map(strtoupper($method), $attribute->getRegistrableRoute(), function (ServerRequestInterface $request, array $arguments) use (
# continue;
#}
#$this->registeredRoutes[$attribute->getRoute().$method] = true;
$route->map(strtoupper($method), $attribute->getRoute(), function (ServerRequestInterface $request, array $arguments) use (
$container, $route, $attribute $container, $route, $attribute
) : ResponseInterface { ) : ResponseInterface {
$class = $attribute->class; $class = $attribute->class;