Class Router
Core router: - main store for all routes - application request routing process before request dispatching in core - currently matched route store - application url completing - by configured routes into mod_rewrite form - or into query string form, containing controller and action params - params query string building - primitive param value or array value representation possible
public static
|
#
GetInstance( array $routes = array() )
Get singleton instance by configured class In MvcCore app instance, optionaly set routes as first argument. |
public
|
#
__construct( array & $routes = array() )
Create router, optionaly set routes into new instance as first argument. |
public
|
|
public
array
|
|
public
|
#
AddRoutes( array $routes = array(), boolean $prepend = FALSE )
Append or prepend new request routes. Routes definition array shoud have items as array with route configuration definitions, stdClass with route configuration definitions or \MvcCore\Route instance. Keys in given array has to be route names as 'Controller:Action' strings or any custom route names with defined controller name and action name inside route array/stdClass configuration or route instance. |
public
|
#
AddRoute( array|stdClass|
Append or prepend new request route. Route definition array shoud be array with route configuration definition, stdClass with route configuration definition or \MvcCore\Route instance. In configuration definition is required route name, controller, action, pattern and if pattern contains regexp groups, its necessary also to define route reverse. Route name should be defined as 'Controller:Action' string or any custom route name, but then there is necessary to specify controller name and action name inside route array/stdClass configuration or route instance. |
public
|
|
public
|
|
public
|
#
GetRouteToDefaultIfNotMatch( boolean $enable,… )
Get state about request routing to 'Default:Default' route if no route matches. |
public
|
#
SetRouteToDefaultIfNotMatch( boolean $enable = TRUE )
Set route request to 'Default:Default' route if no route matches. |
public
|
#
Route(
Route application request by configured routes list. To route request - custom complete currentRoute property and Params property in referenced application request by current request url. Return routed route as current route as reference. This method is always called from \MvcCore app instance to dispatch controller by result route. |
public
string
|
#
Url( string $controllerActionOrRouteName = 'Index:Index', array $params = array() )
Generates url by: - 'Controller:Action' name and params array (for routes configuration when routes array has keys with 'Controller:Action' strings and routes has not controller name and action name defined inside) - route name and params array (route name is key in routes configuration array, should be any string but routes must have information about controller name and action name inside) Result address should have two forms: - nice rewrited url by routes configuration (for apps with .htaccess supporting url_rewrite and when first param is key in routes configuration array) - for all other cases is url form: index.php?controller=ctrlName&action=actionName (when first param is not founded in routes configuration array) |
protected
string
|
#
urlByQueryString( string $controllerActionOrRouteName, array $params )
Complete url with all data in query string |
protected
string
|
#
urlByRoute( string $controllerActionOrRouteName, array $params )
Complete url by route instance reverse info |
protected
|
#
routeByControllerAndActionQueryString( string $controllerName, string $actionName )
Complete current route and request params by query string |
protected
|
|
protected static
string[]
|
#
completeControllerActionParam( string $dashed = '' )
Complete controller and action names in both forms - dashed and pascal case |
protected static
|
$instance
Current singleton instance |
|
protected
|
$request
Current application request |
|
protected
array
|
$routes
All application routes to route request |
#
array()
|
protected
array
|
$urlRoutes
All application routes to build url |
#
array()
|
protected
|
$currentRoute
Current application http routes |
#
NULL
|
protected
boolean
|
$routeToDefaultIfNotMatch
Route request to Default:Default route if no route matches. |
#
FALSE
|