Example #1
0
 /**
  * Add a route to the underlying router.
  *
  * Adds the route to the Aura.Router, using the path as the name, and a
  * middleware value equivalent to the middleware in the Route instance.
  *
  * If HTTP methods are defined (and not the wildcard), they are imploded
  * with a pipe symbol and added as server REQUEST_METHOD criteria.
  *
  * If tokens or values are present in the options array, they are also
  * added to the router.
  *
  * @param Route $route
  */
 public function addRoute(Route $route)
 {
     $auraRoute = $this->router->add($route->getPath(), $route->getPath(), $route->getMiddleware());
     $httpMethods = $route->getAllowedMethods();
     if (is_array($httpMethods)) {
         $auraRoute->setServer(['REQUEST_METHOD' => implode('|', $httpMethods)]);
     }
     foreach ($route->getOptions() as $key => $value) {
         switch ($key) {
             case 'tokens':
                 $auraRoute->addTokens($value);
                 break;
             case 'values':
                 $auraRoute->addValues($value);
                 break;
         }
     }
 }
Example #2
0
 /**
  * Add a route to the underlying router.
  *
  * Adds the route to the Aura.Router, using the path as the name, and a
  * middleware value equivalent to the middleware in the Route instance.
  *
  * If HTTP methods are defined (and not the wildcard), they are imploded
  * with a pipe symbol and added as server REQUEST_METHOD criteria.
  *
  * If tokens or values are present in the options array, they are also
  * added to the router.
  *
  * @param Route $route
  */
 public function addRoute(Route $route)
 {
     $path = $route->getPath();
     $auraRoute = $this->router->add($route->getName(), $path, $route->getMiddleware());
     foreach ($route->getOptions() as $key => $value) {
         switch ($key) {
             case 'tokens':
                 $auraRoute->addTokens($value);
                 break;
             case 'values':
                 $auraRoute->addValues($value);
                 break;
         }
     }
     $allowedMethods = $route->getAllowedMethods();
     if (Route::HTTP_METHOD_ANY === $allowedMethods) {
         return;
     }
     $auraRoute->setServer(['REQUEST_METHOD' => implode('|', $allowedMethods)]);
     if (array_key_exists($path, $this->routes)) {
         $allowedMethods = array_merge($this->routes[$path], $allowedMethods);
     }
     $this->routes[$path] = $allowedMethods;
 }