Пример #1
0
 public function __invoke(RouteCollector $router)
 {
     $routes = $this->collection->all();
     foreach ($routes as $name => $route) {
         $router->addRoute($route->getMethods(), $route->getPath(), $name);
     }
 }
Пример #2
0
 public function processRequest(ServerRequestInterface $request) : int
 {
     $ret = $this->dispatcher->dispatch($request->getMethod(), $request->getUri()->getPath());
     switch ($ret[0]) {
         case Dispatcher::FOUND:
             $this->route = $this->collection->getRoute($ret[1]);
             $this->vars = $ret[2];
             return RouterInterface::STATUS_FOUND;
         case Dispatcher::METHOD_NOT_ALLOWED:
             $this->allowed = $ret[1];
             return RouterInterface::STATUS_NOT_ALLOWED;
         default:
             return RouterInterface::STATUS_NOT_FOUND;
     }
 }
Пример #3
0
 protected function parseRoute(array $route, CollectionInterface $collection, string $prefix = '')
 {
     $route = $this->processRouteConfig($route);
     $path = $this->cleanRoutePath($route['path'], $prefix);
     $collection->withRoute($route['name'], new Route($route['methods'], $path, $route['call']));
 }
Пример #4
0
 public function withRoutes(CollectionInterface $routes)
 {
     $this->routes = array_merge($this->routes, $routes->all());
 }