-
getDefaults() : void
-
-
getMethod() : void
-
getError() : void
-
Constructs a route. Each {key} will be translated to a regular expression
-
Tests if the route matches a given URI and method.
-
Tests if the route allows a given method.
-
Generates a URI for the current route based on the parameters given. (AKA. reverse route)
-
zephir_init_properties_Ice_Mvc_Route() : void
-
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 expressionusing a default regular expression pattern. You can override the default pattern by providing a pattern for the key:
It is also possible to create optional segments by using parentheses in the URI definition:// 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" => "."]);
// 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()