/**
  * Adds the supplied route to the matched route data map
  *
  * @param \Viserio\Contracts\Routing\Route $route
  * @param array                            $parameterIndexNameMap
  */
 public function addRoute(RouteContract $route, array $parameterIndexNameMap)
 {
     $this->httpMethodRouteMap[] = [$route->getMethods(), [$parameterIndexNameMap, $route->getIdentifier()]];
 }
 /**
  * Add the route to any look-up tables if necessary.
  *
  * @param \Viserio\Contracts\Routing\Route $route
  */
 protected function addLookups(RouteContract $route)
 {
     // If the route has a name, we will add it to the name look-up table so that we
     // will quickly be able to find any route associate with a name and not have
     // to iterate through every route every time we need to perform a look-up.
     $action = $route->getAction();
     if (isset($action['as'])) {
         $this->nameList[$action['as']] = $route;
     }
     // When the route is routing to a controller we will also store the action that
     // is used by the route. This will let us reverse route to controllers while
     // processing a request and easily generate URLs to the given controllers.
     if (isset($action['controller'])) {
         $this->actionList[trim($action['controller'], '\\')] = $route;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function process(ServerRequestInterface $request, DelegateInterface $delegate)
 {
     // Add route to the request's attributes in case a middleware or handler needs access to the route
     $request = $request->withAttribute('route', $this->route);
     return $this->route->run($request);
 }
Exemple #4
0
 /**
  * Add the necessary where clauses to the route based on its initial registration.
  *
  * @param \Viserio\Contracts\Routing\Route $route
  *
  * @return \Viserio\Contracts\Routing\Route
  */
 protected function addWhereClausesToRoute(RouteContract $route) : RouteContract
 {
     $where = $route->getAction()['where'] ?? [];
     $patern = array_merge($this->patterns, $where);
     foreach ($patern as $name => $value) {
         $route->where($name, $value);
     }
     return $route;
 }