I want to get the name of the current I route in a middleware class. Previously (in Slim 2.*) you could fetch the current route like so:
$route = $this->ap
Does the following provide you with sufficient information you require or do you also need the 'request' bit in routeInfo?
$app->getContainer()->get('router')->dispatch($req);
If you also require the 'request' bit then you will need to manually do the same thing dispatchRouterAndPrepareRoute
does.
if ($routeInfo[0] === Dispatcher::FOUND) {
$routeArguments = [];
foreach ($routeInfo[2] as $k => $v) {
$routeArguments[$k] = urldecode($v);
}
$route = $router->lookupRoute($routeInfo[1]);
$route->prepare($request, $routeArguments);
// add route to the request's attributes in case a middleware or handler needs access to the route
$request = $request->withAttribute('route', $route);
}
$routeInfo['request'] = [$request->getMethod(), (string) $request->getUri()];
Hope this helps.