Example #1
0
 /**
  * Maps the route into routing table
  *
  * @param    Route   $route  A route instance
  * @return   Router  Returns current route instance
  */
 public function map(Route $route)
 {
     list($path, $groupMiddleware) = $this->processed;
     if ($path != '') {
         $route->setPath($path . $route->getPath());
     }
     if (!empty($groupMiddleware)) {
         $route->addMiddleware($groupMiddleware);
     }
     //Appends route to routing table.
     //We are using Trie search data structure.
     $this->routingTable->appendRoute($route);
     if ($route->getName() !== null) {
         //This is the named route
         if (isset($this->namedRoutes[$route->getName()])) {
             throw new \RuntimeException(sprintf("The Route with the name '%s' alredy exists", $route->getName()));
         } else {
             $this->namedRoutes[$route->getName()] = $route;
         }
     }
     return $this;
 }