Esempio n. 1
0
 /**
  * Create a new Route instance.
  *
  * @param  string  $method
  * @param  string  $uri
  * @param  array   $action
  * @param  array   $parameters
  */
 public function __construct($method, $uri, $action, $parameters = array())
 {
     $this->uri = $uri;
     $this->method = $method;
     $this->action = $action;
     // Determine the bundle in which the route was registered. We will know
     // the bundle by using the bundle::handles method, which will return
     // the bundle assigned to that URI.
     $this->bundle = Bundle::handles($uri);
     // We'll set the parameters based on the number of parameters passed
     // compared to the parameters that were needed. If more parameters
     // are needed, we'll merge in defaults.
     $this->parameters($action, $parameters);
 }
 /**
  * Search the routes for the route matching a method and URI.
  *
  * @param  string   $method
  * @param  string   $uri
  * @return Route
  */
 public static function route($method, $uri)
 {
     Bundle::start($bundle = Bundle::handles($uri));
     $routes = (array) static::method($method);
     // Of course literal route matches are the quickest to find, so we will
     // check for those first. If the destination key exists in the routes
     // array we can just return that route now.
     if (array_key_exists($uri, $routes)) {
         $action = $routes[$uri];
         return new Route($method, $uri, $action);
     }
     // If we can't find a literal match we'll iterate through all of the
     // registered routes to find a matching route based on the route's
     // regular expressions and wildcards.
     if (!is_null($route = static::match($method, $uri))) {
         return $route;
     }
 }
Esempio n. 3
0
 public static function route($method, $uri)
 {
     Bundle::start($bundle = Bundle::handles($uri));
     $routes = (array) static::method($method);
     if (array_key_exists($uri, $routes)) {
         $action = $routes[$uri];
         return new Route($method, $uri, $action);
     }
     if (!is_null($route = static::match($method, $uri))) {
         return $route;
     }
 }