コード例 #1
0
ファイル: FileProvider.php プロジェクト: phurity/router
 /**
  * Parses the routes from the route entry array.
  * @param array[] $definitions List of simple route entries
  * @return array[] Parsed routes definitions
  */
 private function parseRoutes(array $definitions) : array
 {
     $collector = new RouteCollector();
     foreach ($definitions as list($methods, $path, $handler)) {
         $collector->map($methods, $path, $handler);
     }
     return $collector->getRoutes();
 }
コード例 #2
0
 public function parse(RouteCollector $collector, array $patterns, $parentPrefix = '')
 {
     foreach ($this->getPatterns() as $pattern => $route) {
         if (isset($route['name'])) {
             $patternParams = [$pattern, $route['name']];
         } else {
             $patternParams = $pattern;
         }
         if (is_string($route['callback'])) {
             $callback = explode(':', $route['callback']);
         } else {
             $callback = $route['callback'];
         }
         $collector->any($patternParams, $callback);
     }
 }
コード例 #3
0
ファイル: Router.php プロジェクト: hunslater/aerys
 private function buildRouter(RouteCollector $rc, Server $server)
 {
     $allowedMethods = [];
     foreach ($this->routes as list($method, $uri, $actions)) {
         $allowedMethods[] = $method;
         $rc->addRoute($method, $uri, $this->bootRouteTarget($actions));
     }
     $originalMethods = $server->getOption("allowedMethods");
     if ($server->getOption("normalizeMethodCase")) {
         $allowedMethods = array_map("strtoupper", $allowedMethods);
     }
     $allowedMethods = array_merge($allowedMethods, $originalMethods);
     $allowedMethods = array_unique($allowedMethods);
     $server->setOption("allowedMethods", $allowedMethods);
 }
コード例 #4
0
ファイル: Collector.php プロジェクト: opis-colibri/system
 /**
  * Collect routes
  *
  * @param RouteCollector $route
  */
 public function routes(RouteCollector $route)
 {
     $route->bind('html', Callback::class . '::htmlPageInstance');
 }