ice framework documentation ice doc v1.10.1
Methods
  • getDefaults() : void
  • setDefaults(variable $defaults) : void
  • getMethod() : void
  • getError() : void
  • __construct(string $uri, array $regexMap, variable $method) : void
    Constructs a route. Each {key} will be translated to a regular expression
  • matches(string $uri, string $method) : void
    Tests if the route matches a given URI and method.
  • checkMethod(string $method) : void
    Tests if the route allows a given method.
  • uri(array $params) : void
    Generates a URI for the current route based on the parameters given. (AKA. reverse route)
Methods Details
  • public function getDefaults()

  • public function setDefaults(variable $defaults)

  • public function getMethod()

  • public function getError()

  • public function __construct(string $uri, array $regexMap, variable $method)

    Constructs a route. Each {key} will be translated to a regular expression
    using a default regular expression pattern. You can override the default pattern by providing a pattern for the key:
    
             // This route will only match when {id} is a digit
             new Route("/blog/{action}/{id}", ["id" => "\d+"], ['GET', 'POST']);
         
             // This route will match when {path} is anything
             new Route("/{path}", ["path" => "."]);
         
    It is also possible to create optional segments by using parentheses in the URI definition:
    
             // This is the standard default route, and no keys are required
             new Route('/{module}[/{controller}[/{action}[/{id}[/params]]]]');
         
             // This route only requires the {file} key
             new Route('[/{path}/]{file}[.{ext}]', ['path' => '.', 'ext' => '\w+']);
         
    
             $route = new Route($uri, $regex, ['GET', 'POST']);
         
  • public function matches(string $uri, string $method)

    Tests if the route matches a given URI and method.
    
             // Params: controller = blog, action = edit, id = 10
             $params = route->matches("/blog/edit/10");
         
  • public function checkMethod(string $method)

    Tests if the route allows a given method.
  • public function uri(array $params)

    Generates a URI for the current route based on the parameters given. (AKA. reverse route)
    
             // Using the "default" route: /blog/post/10
             $uri = $route->uri(["controller" => "blog", "action" => "post", "id" => 10]);
             if (!$uri) echo $route->getError();
         
  • internal function zephir_init_properties_Ice_Mvc_Route()