Ejemplo n.º 1
0
 /**
  * Creates a new route. Sets the URI and regular expressions for keys.
  * Routes should always be created with [Route::set] or they will not
  * be properly stored.
  *
  *     $route = new Route($uri, $regex);
  *
  * The $uri parameter should be a string for basic regex matching.
  *
  *
  * @param   string  $uri    route URI pattern
  * @param   array   $regex  key patterns
  * @return  void
  * @uses    Route::_compile
  */
 public function __construct($uri = NULL, $method = NULL, $regex = NULL)
 {
     if ($uri === NULL) {
         // Assume the route is from cache
         return;
     }
     if (!empty($uri)) {
         $this->_uri = $uri;
     }
     if ($method !== NULL) {
         $this->_method = $method;
     } else {
         throw new RouteException('There is no request method specified');
     }
     if ($regex !== NULL) {
         $this->_regex = $regex;
     }
     // Store the compiled regex locally
     $this->_route_regex = Route::compile($uri, $regex);
 }