public
|
#
__construct( string|array $patternOrConfig,…, string $controllerAction,…, array $defaults,…, array $constraints,…, array $advancedConfiguration,… )
Create new route instance. First argument could be configuration array
with all necessary constructor values or all separated arguments - first
is route pattern value to parse into match and reverse values, then
controller with action, params default values and constraints.
Example:
new Route([
"pattern" => "/products-list/<name>/<color>",
"controllerAction" => "Products:List",
"defaults" => ["name" => "default-name", "color" => "red"],
"constraints" => ["name" => "[^/]*", "color" => "[a-z]*"]
]);
or:
new Route(
"/products-list/<name>/<color>",
"Products:List",
["name" => "default-name", "color" => "red"],
["name" => "[^/]*", "color" => "[a-z]*"]
);
or:
new Route([
"name" => "products_list",
"match" => "#^/products\-list/(?<name>[^/]*)/(?<color>[a-z]*)(?=/$|$)#",
"reverse" => "/products-list/<name>/<color>",
"controller" => "Products",
"action" => "List",
"defaults" => ["name" => "default-name", "color" => "red"],
]);
Create new route instance. First argument could be configuration array
with all necessary constructor values or all separated arguments - first
is route pattern value to parse into match and reverse values, then
controller with action, params default values and constraints.
Example:
new Route([ "pattern" => "/products-list/<name>/<color>", "controllerAction" => "Products:List", "defaults" => ["name" => "default-name", "color" => "red"], "constraints" => ["name" => "[^/]*", "color" => "[a-z]*"]
]);
or:
new Route( "/products-list/<name>/<color>", "Products:List", ["name" => "default-name", "color" => "red"], ["name" => "[^/]*", "color" => "[a-z]*"]
);
or:
new Route([ "name" => "products_list", "match" => "#^/products\-list/(?<name>[^/]*)/(?<color>[a-z]*)(?=/$|$)#", "reverse" => "/products-list/<name>/<color>", "controller" => "Products", "action" => "List", "defaults" => ["name" => "default-name", "color" => "red"],
]);
Parameters
- $patternOrConfig,…
Required, configuration array or route pattern value
to parse into match and reverse patterns.
- $controllerAction,…
Optional, controller and action name in pascal case
like: "Products:List" .
- $defaults,…
Optional, default param values like:
["name" => "default-name", "page" => 1] .
- $constraints,…
Optional, params regular expression constraints for
regular expression match function no "match" record
in configuration array as first argument defined.
- $advancedConfiguration,…
Optional, http method to only match requests by this
method. If NULL (by default), request with any http
method could be matched by this route. Given value is
automatically converted to upper case.
Overrides
|