router->group(rtrim($urlBase, "/"), function (RouteGroup $route) use ($container) { foreach($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) { $route->map(strtoupper($method), $attribute->getRoute(), function (ServerRequestInterface $request, array $arguments) use ( $container, $route, $attribute ) : ResponseInterface { $class = $attribute->class; $method = $attribute->classMethod; $object = $container->get($class); $this->eventManager->execute(Event\RoutingMapRoutes::class, $this, $container, $request, $attribute); $container->set(ServerRequestInterface::class, $request); return $this->response ?? $object->$method($request, $arguments); }); } } }); } }