Orion PHP  0.11.12
The PHP5.3 framework
Orion\Core\Route Class Reference

List of all members.

Public Member Functions

 decode ()
 decodeAuto ()
 addRule ($regex, $method)
 setDefaultMethod ($method)
 setErrorMethod ($method)
 getRules ()

Public Attributes

const E_NORULE = 1024

Private Attributes

 $defaultMethod = 'index'
 $errorMethod = 'error'
 $rules = array()

Detailed Description

Orion Route class

Handles routing rules and URI parsing.

Author:
Thibaut Despoulain BSD 4-clauses
Version:
0.11.12

Definition at line 15 of file route.php.


Member Function Documentation

Orion\Core\Route::addRule ( regex,
method 
)

Adds a new routing rule to parse URIs. Rules are identified by their regex, thus, it's impossible to have the same regex for two different functions.
'index' method rule (blank regex) is implicit and thus doesn't needs to be added, but you can still define a 'index.html' rule mapped to the _index function. Note that while the rule is implicit, the function itself as to be manualy overriden in the module.

Parameters:
string$regexMust be either a PCRE regex or a custom Easy-regex
Example : 'article-?-@-*.html' is the Easy-regex equivalent to '#article\-([a-zA-Z0-9_-]+)\-(+)-(.*?)\.html$#') If the method has a dynamic number of arguments or facultative arguments, you have to add a rule for each possible URI.
string$methodthe method name to be called (without any security character, see OrionModule callback for more)

Definition at line 128 of file route.php.

Orion\Core\Route::decode ( )

Decode current request URI into a usable RouteMethod.
It's then possible to retreive the method to call and the arguments via the following getters:
RouteMethod->getMethod();
RouteMethod->getArgs();
RouteMethod->getURI();

Returns:
RouteMethod
See also:
RouteMethod

Definition at line 54 of file route.php.

Orion\Core\Route::decodeAuto ( )

Decode current request URI into a usable OrionRouteMethod using an automated parser.
It's then possible to retreive the method to call and the arguments via the following getters:
OrionRouteMethod->getMethod();
OrionRouteMethod->getArgs();
OrionRouteMethod->getURI();

Returns:
OrionRouteMethod
See also:
OrionRouteMethod

Definition at line 86 of file route.php.

Orion\Core\Route::getRules ( )

Get defined rules

Returns:
array Rules

Definition at line 155 of file route.php.

Orion\Core\Route::setDefaultMethod ( method)

Set the default method to be called with empty or '/' URI.

Parameters:
string$method

Definition at line 137 of file route.php.

Orion\Core\Route::setErrorMethod ( method)

Set the error method to be called if no rule match is found or if module is called without a route.

Parameters:
string$method

Definition at line 146 of file route.php.


Member Data Documentation

Orion::Core\Route::$defaultMethod = 'index' [private]

Definition at line 28 of file route.php.

Orion::Core\Route::$errorMethod = 'error' [private]

Definition at line 34 of file route.php.

Orion::Core\Route::$rules = array() [private]

Definition at line 41 of file route.php.

const Orion::Core\Route::E_NORULE = 1024

The 1024 error is passed as argument to the error method when no matching rule is found.

Definition at line 20 of file route.php.


The documentation for this class was generated from the following file: