/** * @return JsonModel */ public function matchRouteAction() { $data = $this->params()->fromQuery(); $route = null; if (isset($data['method']) && !empty($data['method']) && isset($data['url']) && !empty($data['url'])) { if (null !== ($routeName = $this->routeMatcher->match($data['method'], $data['url']))) { $route = $this->routeCollection->getRoute($routeName); $route = ['name' => $route->getName(), 'url' => $route->getUrl(), 'controller' => $route->getController(), 'action' => $route->getAction()]; } } return new JsonModel(['requestedRouteData' => $data, 'routeMatch' => $route]); }
public function matchAction() { /** @var Request $request */ $request = $this->getRequest(); $method = strtoupper($request->getParam('method')); $url = $request->getParam('url'); $match = $this->routeMatcher->match($method, $url); if (null !== $match) { $route = $this->routeCollection->getRoute($match); $this->console->writeLine(sprintf('A match was found for %s "%s"', $method, $url), ColorInterface::GREEN); $this->console->write(' Name: '); $this->console->writeLine($route->getName(), ColorInterface::LIGHT_WHITE); $this->console->write(' URL: '); $this->console->writeLine($route->getUrl(), ColorInterface::LIGHT_WHITE); $this->console->write(' Controller: '); $this->console->writeLine($route->getController(), ColorInterface::LIGHT_WHITE); $this->console->write(' Action: '); $this->console->writeLine($route->getAction(), ColorInterface::LIGHT_WHITE); } else { $this->console->writeLine(sprintf('No match found for %s "%s"', $method, $url), ColorInterface::RED); } }