Ejemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $routes = array();
     foreach (\Stativo\Core\Route::all() as $name => $route) {
         $routes[] = [$name, $route->_uri, is_array($route->_method) ? implode('|', $route->_method) : $route->_method, implode('@', array_map(function ($word) {
             return ucfirst($word);
         }, $route->_defaults)), is_array($route->_middleware) ? implode('|', $route->_middleware) : $route->_middleware];
     }
     $table = new Table($output);
     $table->setHeaders(array('Name', 'Uri', 'Method', 'Defaults', 'Middleware'))->setRows($routes);
     $table->render();
 }
Ejemplo n.º 2
0
 /**
  * Process URI
  * @param  string $uri    uri from url
  * @param  array $routes avalible routes
  * @return array         params and route
  */
 public static function process_uri($uri, $routes = null)
 {
     // Load routes
     $routes = empty($routes) ? Route::all() : $routes;
     $params = null;
     foreach ($routes as $name => $route) {
         // We found something suitable
         if ($params = $route->matches($uri, $name)) {
             return array('params' => $params, 'route' => $route);
         }
     }
     return null;
 }