/** * @param string $method * @param string $url * * @return null|string */ public function match($method, $url) { $request = new Request(); $request->setMethod($method); $request->setUri($url); $routeMatch = $this->router->match($request); return $routeMatch instanceof RouteMatch ? $routeMatch->getMatchedRouteName() : null; }
/** * Set the router from the MVC framework * * This will push the route paths into the request as parameters * * @param RouteStack $router */ public function setRouter(RouteStackInterface $router) { $this->router = $router; // now extract the route elements and set them as params $route_match = $router->match($this); if ($route_match instanceof RouteMatch) { foreach ($route_match->getParams() as $name => $value) { $this->setParam($name, $value); } } }