Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcMvcRouter

MvcTools::ezcMvcRouter

Class ezcMvcRouter

The abstract router that you need to inherit from to supply your routes.

Source for this file: /MvcTools/src/router.php

Version:   //autogentag//

Member Variables

protected ezcMvcRequest $request
Contains the request object
protected array(ezcMvcRoute) $routes = array()
Contains all the user defined routes.

Method Summary

public static void prefix( $prefix , $routes )
Loops over all the given routes and adds the prefix $prefix to them
public ezcMvcRouter __construct( $request )
Creates a new router object
public abstract array(ezcMvcRoute) createRoutes( )
User implemented method that should provide all the routes.
public void generateUrl( $routeName , [ $arguments = null] )
Generates an URL back out of a route, including possible arguments
public ezcMvcRoutingInformation getRoutingInformation( )
Returns routing information, including a controller classname from the set of routes.

Methods

prefix

static void prefix( mixed $prefix , array(ezcMvcRoute) $routes )

Loops over all the given routes and adds the prefix $prefix to them

The methods loops over all the routes in the $routes variables and calls the prefix() method on the route with the $prefix. The $prefix should be a prefix that the route understands.

Parameters:
Name Type Description
$prefix mixed
$routes array(ezcMvcRoute)
Exceptions:
Type Description
ezcMvcRegexpRouteException if the prefix can not be prepended to one or more of the patterns in the routes.

__construct

ezcMvcRouter __construct( ezcMvcRequest $request )

Creates a new router object

Parameters:
Name Type Description
$request ezcMvcRequest

createRoutes

array(ezcMvcRoute) createRoutes( )

User implemented method that should provide all the routes.

It should return an array of objects that implement the ezcMvcRoute interface. This could be objects of the ezcMvcRegexpRoute class for example.

generateUrl

void generateUrl( mixed $routeName , [ $arguments = null] )

Generates an URL back out of a route, including possible arguments

Parameters:
Name Type Description
$routeName mixed
$arguments array

getRoutingInformation

ezcMvcRoutingInformation getRoutingInformation( )

Returns routing information, including a controller classname from the set of routes.

This method is run by the dispatcher to obtain a controller. It uses the user implemented createRoutes() method from the inherited class to fetch the routes. It then loops over these routes in order - the first one that matches the request returns the routing information. The loop stops as soon as a route has matched. In case none of the routes matched with the request data an exception is thrown.

Exceptions:
Type Description
ezcMvcNoRoutesException when there are no routes defined.
ezcBaseValueException when one of the returned routes was not actually an object implementing the ezcMvcRoute interface.
ezcMvcRouteNotFoundException when no routes matched the request URI.
Documentation generated by phpDocumentor 1.4.3