Zeta Components Manual :: Docs For Class ezcMvcRailsRoute
MvcTools::ezcMvcRailsRoute
Class ezcMvcRailsRoute
Router class that uses rails style expressions for matching routes.
The routes are matched against the uri property of the request object. The matching algorithm works as follows:
- The pattern and URI as returned by getUriString() are split on the / character.
- If the first part of the split *pattern* contains a "." (dot) then the first part of the pattern and the URI are split by ".". The return of this, together with the rest of the original split-by-slash string are concatenated.
- Each of the two arrays are compared with each other with the delimiters being ignored.
- A special case are elements in the pattern that start with a ":". In this case the pattern element and uri element do not need to match. Instead the pattern element creates a named variable with as value the element from the URI array with the same index.
- If not every element matches, the route does not match and false is returned. If everything matches, true is returned.
Source for this file: /MvcTools/src/routes/rails.php
Implements interfaces:
Version: | //autogentag// |
Member Variables
protected string |
$action
Contains the action that the controller should execute. |
protected string |
$controllerClassName
This is the name of the controller class that will be instantiated with the request variables obtained from the route, as well as the default values belonging to a route. |
protected array(string) |
$defaultValues
The default values for the variables that are send to the controller. The route matchers can override those default values |
protected string |
$pattern
This property contains the pattern |
Method Summary
public ezcMvcRailsRoute |
__construct(
$pattern
, $controllerClassName
, [ $action
= null] , [ $defaultValues
= array()] )
Constructs a new ezcMvcRailsRoute with $pattern. |
public void |
generateUrl(
[ $arguments
= null] )
Generates an URL back out of a route, including possible arguments |
protected string |
getUriString(
$request
)
Returns the request information that the matches() method will match the pattern against. |
protected bool |
match(
$request
, &$matches
, $matches
)
This method performs the actual pattern match against the $request's URI. |
public null|ezcMvcRoutingInformation |
matches(
$request
)
Evaluates the URI against this route. |
public void |
prefix(
$prefix
)
Adds the $prefix to the route's pattern. |
Methods
__construct
Constructs a new ezcMvcRailsRoute with $pattern.
When the route is matched (with the match() method), the route instantiates an object of the class $controllerClassName.
Parameters:
Name | Type | Description |
---|---|---|
$pattern |
string | |
$controllerClassName |
string | |
$action |
string | |
$defaultValues |
array(string) |
generateUrl
Generates an URL back out of a route, including possible arguments
Parameters:
Name | Type | Description |
---|---|---|
$arguments |
array |
Implementation of:
Method | Description |
---|---|
ezcMvcReversibleRoute::generateUrl() |
Generates an URL back out of a route, including possible arguments |
getUriString
Returns the request information that the matches() method will match the pattern against.
Parameters:
Name | Type | Description |
---|---|---|
$request |
ezcMvcRequest |
match
This method performs the actual pattern match against the $request's URI.
Parameters:
Name | Type | Description |
---|---|---|
$request |
ezcMvcRequest | |
$matches |
array(string) | |
&$matches |
matches
Evaluates the URI against this route.
The method first runs the match. If the pattern matches, it then creates an object containing routing information and returns it. If the route's pattern did not match it returns null.
Parameters:
Name | Type | Description |
---|---|---|
$request |
ezcMvcRequest |
Implementation of:
Method | Description |
---|---|
ezcMvcRoute::matches() |
Returns routing information if the route matched, or null in case the route did not match. |
prefix
Adds the $prefix to the route's pattern.
It's up to the developer to provide a meaningfull prefix. In this case, it needs to be a pattern just like the normal pattern.
Parameters:
Name | Type | Description |
---|---|---|
$prefix |
mixed |
Implementation of:
Method | Description |
---|---|
ezcMvcRoute::prefix() |
Adds a prefix to the route. |