Home  Support  API

ChainedRouter Class Reference
[Routing]


LILO route chain implementation.

Aggregates routes and lookups the first route that matches the request without an explicit RouteException.

Use ChainedRouter::route() for filling the chain with your own common application-wide routes.

Example:

 $router->route("blogEntry", "/blog:controller/entry:action/?id");

Definition at line 34 of file ChainedRouter.class.php.

Inheritance diagram for ChainedRouter:
Inheritance graph

List of all members.

Public Member Functions

 __construct (IRouteDispatcher $dispatcher)
 addRoute ($name, Route $route)
 Appends the Route to the chain.
 addRoutes (array $routes)
 Appends the set of named routes to the chain.
 appendRoute ($name, Route $route)
 Appends the Route to the chain.
 getDefaultDispatcher ()
 Gets the default dispatcher for newly created routes.
 getFallbackTrace (Trace $parentTrace)
 Gets the Trace suitable for situation when the matched Trace was unable to handle the IWebContext.
 getRoute ($name)
 Gets the named Route.
 getTrace (IWebContext $webContext)
 Gets the Trace that can handle IWebContext, or null if no Route found that matches the IWebContext.
 prependRoute ($name, Route $route)
 Prepends the Route to the chain.
 route ($name, $uri=null, array $parameters=array())
 Smart route assembler.
 setFallbackRoute (Route $route)
 Sets the fallback Route.

Constructor & Destructor Documentation

ChainedRouter::__construct ( IRouteDispatcher dispatcher  ) 
Parameters:
IRouteDispatcher $dispatcher a default dispatcher for routes

Definition at line 59 of file ChainedRouter.class.php.


Member Function Documentation

ChainedRouter::addRoute ( name,
Route route 
)

Appends the Route to the chain.

Parameters:
string $name name of the Route to append
Route $route route object to append
Returns:
ChainedRouter itself

Definition at line 168 of file ChainedRouter.class.php.

References appendRoute().

Referenced by addRoutes(), and route().

ChainedRouter::addRoutes ( array $  routes  ) 

Appends the set of named routes to the chain.

Parameters:
array $routes an associative array of Route object, where key is the name of the Route
Returns:
ChainedRouter itself

Definition at line 196 of file ChainedRouter.class.php.

References addRoute().

ChainedRouter::appendRoute ( name,
Route route 
)

Appends the Route to the chain.

Parameters:
string $name name of the Route to append
Route $route route object to append
Returns:
ChainedRouter itself

Definition at line 213 of file ChainedRouter.class.php.

References Assert::isFalse(), and Assert::isScalar().

Referenced by addRoute().

ChainedRouter::getDefaultDispatcher (  ) 

Gets the default dispatcher for newly created routes.

Returns:
IRouteDispatcher

Definition at line 69 of file ChainedRouter.class.php.

ChainedRouter::getFallbackTrace ( Trace parentTrace  ) 

Gets the Trace suitable for situation when the matched Trace was unable to handle the IWebContext.

Parameters:
Trace $parentTrace trace that was unable to handle the IWebContext
Returns:
Trace

Implements IRouter.

Definition at line 151 of file ChainedRouter.class.php.

References Trace::getWebContext().

ChainedRouter::getRoute ( name  ) 

Gets the named Route.

Parameters:
string $name name of the Route
Exceptions:
ArgumentException if named route not found
Returns:
Route

Implements IRouteTable.

Definition at line 243 of file ChainedRouter.class.php.

References Assert::isScalar().

ChainedRouter::getTrace ( IWebContext webContext  ) 

Gets the Trace that can handle IWebContext, or null if no Route found that matches the IWebContext.

Parameters:
IWebContext $webContext the route should be matched against
Returns:
Trace|null

Implements IRouter.

Definition at line 130 of file ChainedRouter.class.php.

ChainedRouter::prependRoute ( name,
Route route 
)

Prepends the Route to the chain.

Parameters:
string $name name of the Route to append
Route $route route object to append
Returns:
ChainedRouter itself

Definition at line 232 of file ChainedRouter.class.php.

References Assert::isFalse(), and Assert::isScalar().

ChainedRouter::route ( name,
uri = null,
array $  parameters = array() 
)

Smart route assembler.

Accepts the name of the route to be assembled, URI to be used as a template for the rules.

Example:

 $router->route("blogEntry", "/blog:controller/entry:action/?id");

In future, the third parameter will be allowed to contain various objects that will be smartly mapped to appropriate rules.

Parameters:
string $name name of the route
string $uri URI that will be used as request variables template
array $parameters array of parameters to be appended to Trace
Returns:
ChainedRouter itself

Definition at line 92 of file ChainedRouter.class.php.

References addRoute(), WebRequestPart::GET, Assert::isScalar(), and Assert::isScalarOrNull().

ChainedRouter::setFallbackRoute ( Route route  ) 

Sets the fallback Route.

Fallback Route will be used to handle situation when no Route matched an IWebContext

Returns:
ChainedRouter itself

Definition at line 182 of file ChainedRouter.class.php.


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