Methods summary
public static
MvcCore\Route
|
#
CreateInstance( string|array $patternOrConfig = NULL, string $controllerAction = NULL, array $defaults = [], array $constraints = [], array $advancedConfiguration = [] )
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 if no "match"
property in config 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.
Returns
Inheritdocs
|
public
|
#
__construct( string|array $patternOrConfig = NULL, string $controllerAction = NULL, 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.
|
protected
|
#
constructDataPatternsDefaultsConstraintsFilters( stdClass & $data )
If route is initialized by single array argument with all data,
initialize following properties if those exist in given object:
pattern , match and reverse . If properties defaults , constraints
and filters exist in given object, initialize them by setter methods.
If route is initialized by single array argument with all data,
initialize following properties if those exist in given object:
pattern , match and reverse . If properties defaults , constraints
and filters exist in given object, initialize them by setter methods.
Parameters
- $data
Object containing properties pattern ,
match , reverse , filters and defaults .
|
protected
|
#
constructDataCtrlActionName( stdClass & $data )
If route is initialized by single array argument with all data,
initialize following properties if those exist in given object:
controller , action (or controllerAction ) and name .
If route is initialized by single array argument with all data,
initialize following properties if those exist in given object:
controller , action (or controllerAction ) and name .
Parameters
- $data
Object containing properties controller ,
action (or controllerAction ) and name .
|
protected
|
#
constructDataAdvConf( stdClass & $data )
If route is initialized by single array argument with all data,
initialize following properties if those exist in given object:
method , redirect and absolute .
If route is initialized by single array argument with all data,
initialize following properties if those exist in given object:
method , redirect and absolute .
Parameters
- $data
Object containing properties method ,
redirect and absolute .
|
protected
|
#
constructVarsPatternDefaultsConstraintsFilters( string|null & $pattern, array|null & $defaults, array|null & $constraints, array & $advCfg )
If route is initialized by each constructor function arguments,
initialize pattern and defaults , if those are not NULL and
initialize constraints by setter if not NULL and initialize filter in
and filter out by filter setter from $advCfg array if there are those
filter keys found.
If route is initialized by each constructor function arguments,
initialize pattern and defaults , if those are not NULL and
initialize constraints by setter if not NULL and initialize filter in
and filter out by filter setter from $advCfg array if there are those
filter keys found.
Parameters
- $pattern
- Route pattern string.
- $defaults
Route defaults array, keys are param
names, values are default values.
- $constraints
Route params regular expression
constraints array, keys are param
names, values are allowed regular
expression rules.
- $advCfg
An array with possible keys in and
out to define route filter in and
filter out callable.
|
protected
|
#
constructVarCtrlActionNameByData( string|null & $ctrlAction )
If route is initialized by each constructor function arguments,
initialize controller and action , if any of them is defined in given
argument $ctrlAction .
If route is initialized by each constructor function arguments,
initialize controller and action , if any of them is defined in given
argument $ctrlAction .
Parameters
- $ctrlAction
Controller and action combination
definition, it could be "Products:List"
or only "Products:" etc.
|
protected
|
#
constructVarAdvConf( array & $advCfg )
If route is initialized by each constructor function arguments,
initialize method , redirect and absolute .
If route is initialized by each constructor function arguments,
initialize method , redirect and absolute .
Parameters
- $advCfg
An array with possible keys method ,
redirect and absolute .
|
protected
|
#
constructCtrlOrActionByName( array $advCfg,… )
If route is initialized by each constructor function arguments or also
if route is initialized by single array argument with all data, this
function is called to initialize controller and action properties if
those are still NULL . Function tries to initialize those properties
from route action property, if it contains colon char :`.
If route is initialized by each constructor function arguments or also
if route is initialized by single array argument with all data, this
function is called to initialize controller and action properties if
those are still NULL . Function tries to initialize those properties
from route action property, if it contains colon char :`.
Parameters
- $advCfg,…
An array with possible keys method ,
redirect and absolute .
|