/**
  * @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]);
 }
Example #2
0
 /**
  * @return string
  */
 public function export()
 {
     $datetime = DateTime::createFromFormat('U.u', microtime(true));
     $fileName = sprintf('%s/%s_routes_%s.csv', $this->outputDir, Package::NAME, $datetime->format('Ymd-His.u'));
     $fp = fopen($fileName, 'w');
     fputcsv($fp, ['Route name', 'URL', 'Controller', 'Action']);
     foreach ($this->routeCollection->getRoutes() as $route) {
         /* @var Route $route */
         fputcsv($fp, [$route->getName(), $route->getUrl(), $route->getController(), $route->getAction()]);
     }
     fclose($fp);
     return $fileName;
 }
 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);
     }
 }