Axiom (v1.2.0)

A lightweight PHP framework
axRouter Class Reference

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

Detailed Description

Router and dispatcher Class.

Todo:
axRouter long description
Warning:
This class rely on the Axiom class for locale and module settings.
Author:
Delespierre
License:
http://www.gnu.org/licenses/lgpl.html Lesser General Public Licence version 3

Definition at line 18 of file axRouter.class.php.


Member Function Documentation

static axRouter::_getRoute ( url) [static, protected]

Get the route instance that matches the given URL.

Parameters:
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.

Todo:
Describe axRouter::load behavior
Parameters:
string$controller
string$action[optional] [default null] If null will use the index action
Returns:
void

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:

Parameters:
string$params
Returns:
array

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.

Returns:
void

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}
Todo:
Describe completely the route management here

Three prototypes are available:

Parameters:
mixed$templateThe 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
Exceptions:
RuntimeExceptionIf the route cannot be connected (not instance of axRouter)
Returns:
void

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.

Todo:
Describe axRouter::run behavior
Parameters:
mixed$route[optional] [default null]
string$action[optional] [default null]
Exceptions:
RuntimeExceptionIf no controller is found in the route
Returns:
void

Definition at line 97 of file axRouter.class.php.


Field Documentation

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.


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables