Router and dispatcher Class. More...
Static Public Member Functions | |
| static | connect ($template, $params=array(), array $options=array()) |
| Connect a route. | |
| static | run ($route=null, $action=null) |
| Run router. | |
Static Protected Member Functions | |
| static | _load ($controller, $action=null) |
| Invoke the given controller / action and load the corresponding view. | |
| static | _redirect (axRedirectException $exception) |
| Handler for axRedirectException. | |
| static | _parseParamString ($params) |
| Parses a route param string into an array. | |
| static | _getRoute ($url) |
| Get the route instance that matches the given URL. | |
Static Protected Attributes | |
| static | $_routes |
| Routes. | |
| static | $_request |
| axRequest object | |
| static | $_response |
| axResponse object | |
Router and dispatcher Class.
Definition at line 18 of file axRouter.class.php.
| static axRouter::_getRoute | ( | $ | url | ) | [static, protected] |
Get the route instance that matches the given URL.
| string | $url |
Definition at line 259 of file axRouter.class.php.
| static axRouter::_load | ( | $ | controller, |
| $ | action = null |
||
| ) | [static, protected] |
Invoke the given controller / action and load the corresponding view.
| string | $controller | |
| string | $action | [optional] [default null] If null will use the index action |
Definition at line 166 of file axRouter.class.php.
| static axRouter::_parseParamString | ( | $ | params | ) | [static, protected] |
Parses a route param string into an array.
This method allows the Routes to be connected by providing strings as parameters instead of array for practical reasons. These calls are identicals:
| string | $params |
Definition at line 249 of file axRouter.class.php.
| static axRouter::_redirect | ( | axRedirectException $ | exception | ) | [static, protected] |
Handler for axRedirectException.
Will send the proper header to the browser and optionnaly load the ErrorController::redirection view.
Definition at line 227 of file axRouter.class.php.
| static axRouter::connect | ( | $ | template, |
| $ | params = array(), |
||
| array $ | options = array() |
||
| ) | [static] |
Connect a route.
Routes are matched according to a given template. Ttemplates follow the following format:
/[string|{:key<:pattern><:?>}]/...
Examples of valid templates:
/a/b/c
/{:controller}/{:action}
/articles/{:id:\d+}
/{:lang:\w{2}:?}/{:controller}/{:action}
Three prototypes are available:
| mixed | $template | The template or the objet to match the url against |
| mixed | $params | [optional] [default array()] The parameters of the route (must contain at least the controller's name), you may leave it blank if your template catches the controller's name |
| array | $options | [optional] [default array()] The route options |
| RuntimeException | If the route cannot be connected (not instance of axRouter) |
Definition at line 68 of file axRouter.class.php.
| static axRouter::run | ( | $ | route = null, |
| $ | action = null |
||
| ) | [static] |
Run router.
If not route/action is given, the router will determine the route based on the URL. See axRouter::connect() for more information about connecting routes.
| mixed | $route | [optional] [default null] |
| string | $action | [optional] [default null] |
| RuntimeException | If no controller is found in the route |
Definition at line 97 of file axRouter.class.php.
axRequest axRouter::$_request [static, protected] |
axRequest object
Definition at line 30 of file axRouter.class.php.
axResponse axRouter::$_response [static, protected] |
axResponse object
Definition at line 36 of file axRouter.class.php.
array axRouter::$_routes [static, protected] |
Routes.
Definition at line 24 of file axRouter.class.php.