Zend Framework  1.12
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Zend_Controller_Router_Rewrite Class Reference

Public Member Functions

 addDefaultRoutes ()
 Add default routes which are used to mimic basic router behaviour.
 
 addRoute ($name, Zend_Controller_Router_Route_Interface $route)
 Add route to the route chain.
 
 addRoutes ($routes)
 Add routes to the route chain.
 
 addConfig (Zend_Config $config, $section=null)
 Create routes out of Zend_Config configuration.
 
 removeRoute ($name)
 Remove a route from the route chain.
 
 removeDefaultRoutes ()
 Remove all standard default routes.
 
 hasRoute ($name)
 Check if named route exists.
 
 getRoute ($name)
 Retrieve a named route.
 
 getCurrentRoute ()
 Retrieve a currently matched route.
 
 getCurrentRouteName ()
 Retrieve a name of currently matched route.
 
 getRoutes ()
 Retrieve an array of routes added to the route chain.
 
 route (Zend_Controller_Request_Abstract $request)
 Find a matching route to the current PATH_INFO and inject returning values to the Request object.
 
 assemble ($userParams, $name=null, $reset=false, $encode=true)
 Generates a URL path that can be used in URL creation, redirection, etc.
 
 setGlobalParam ($name, $value)
 Set a global parameter.
 
 setChainNameSeparator ($separator)
 Set the separator to use with chain names.
 
 getChainNameSeparator ()
 Get the separator to use for chain names.
 
 useRequestParametersAsGlobal ($use=null)
 Determines/returns whether to use the request parameters as global parameters.
 
- Public Member Functions inherited from Zend_Controller_Router_Abstract
 __construct (array $params=array())
 Constructor.
 
 setParam ($name, $value)
 Add or modify a parameter to use when instantiating an action controller.
 
 setParams (array $params)
 Set parameters to pass to action controller constructors.
 
 getParam ($name)
 Retrieve a single parameter from the controller parameter stack.
 
 getParams ()
 Retrieve action controller instantiation parameters.
 
 clearParams ($name=null)
 Clear the controller parameter stack.
 
 getFrontController ()
 Retrieve Front Controller.
 
 setFrontController (Zend_Controller_Front $controller)
 Set Front Controller.
 

Protected Member Functions

 _getRouteFromConfig (Zend_Config $info)
 Get a route frm a config instance.
 
 _addChainRoutesFromConfig ($name, Zend_Controller_Router_Route_Interface $route, Zend_Config $childRoutesInfo)
 Add chain routes from a config route.
 
 _setRequestParams ($request, $params)
 

Protected Attributes

 $_useDefaultRoutes = true
 
 $_routes = array()
 
 $_currentRoute = null
 
 $_globalParams = array()
 
 $_chainNameSeparator = '-'
 
 $_useCurrentParamsAsGlobal = false
 
- Protected Attributes inherited from Zend_Controller_Router_Abstract
 $_frontController
 
 $_invokeParams = array()
 

Additional Inherited Members

- Public Attributes inherited from Zend_Controller_Router_Abstract
const URI_DELIMITER = '/'
 URI delimiter.
 

Member Function Documentation

_addChainRoutesFromConfig (   $name,
Zend_Controller_Router_Route_Interface  $route,
Zend_Config  $childRoutesInfo 
)
protected

Add chain routes from a config route.

Parameters
string$name
Zend_Controller_Router_Route_Interface$route
Zend_Config$childRoutesInfo
Returns
void
_getRouteFromConfig ( Zend_Config  $info)
protected

Get a route frm a config instance.

Parameters
Zend_Config$info
Returns
Zend_Controller_Router_Route_Interface
_setRequestParams (   $request,
  $params 
)
protected
addConfig ( Zend_Config  $config,
  $section = null 
)

Create routes out of Zend_Config configuration.

Example INI: routes.archive.route = "archive/:year/*" routes.archive.defaults.controller = archive routes.archive.defaults.action = show routes.archive.defaults.year = 2000 routes.archive.reqs.year = "\d+"

routes.news.type = "Zend_Controller_Router_Route_Static" routes.news.route = "news" routes.news.defaults.controller = "news" routes.news.defaults.action = "list"

And finally after you have created a Zend_Config with above ini: $router = new Zend_Controller_Router_Rewrite(); $router->addConfig($config, 'routes');

Parameters
Zend_Config$configConfiguration object
string$sectionName of the config section containing route's definitions
Exceptions
Zend_Controller_Router_Exception
Returns
Zend_Controller_Router_Rewrite
addDefaultRoutes ( )

Add default routes which are used to mimic basic router behaviour.

Returns
Zend_Controller_Router_Rewrite
addRoute (   $name,
Zend_Controller_Router_Route_Interface  $route 
)

Add route to the route chain.

If route contains method setRequest(), it is initialized with a request object

Parameters
string$nameName of the route
Zend_Controller_Router_Route_Interface$routeInstance of the route
Returns
Zend_Controller_Router_Rewrite
addRoutes (   $routes)

Add routes to the route chain.

Parameters
array$routesArray of routes with names as keys and routes as values
Returns
Zend_Controller_Router_Rewrite
assemble (   $userParams,
  $name = null,
  $reset = false,
  $encode = true 
)

Generates a URL path that can be used in URL creation, redirection, etc.

Parameters
array$userParamsOptions passed by a user used to override parameters
mixed$nameThe name of a Route to use
bool$resetWhether to reset to the route defaults ignoring URL params
bool$encodeTells to encode URL parts on output
Exceptions
Zend_Controller_Router_Exception
Returns
string Resulting absolute URL path

Implements Zend_Controller_Router_Interface.

getChainNameSeparator ( )

Get the separator to use for chain names.

Returns
string
getCurrentRoute ( )

Retrieve a currently matched route.

Exceptions
Zend_Controller_Router_Exception
Returns
Zend_Controller_Router_Route_Interface Route object
getCurrentRouteName ( )

Retrieve a name of currently matched route.

Exceptions
Zend_Controller_Router_Exception
Returns
Zend_Controller_Router_Route_Interface Route object
getRoute (   $name)

Retrieve a named route.

Parameters
string$nameName of the route
Exceptions
Zend_Controller_Router_Exception
Returns
Zend_Controller_Router_Route_Interface Route object
getRoutes ( )

Retrieve an array of routes added to the route chain.

Returns
array All of the defined routes
hasRoute (   $name)

Check if named route exists.

Parameters
string$nameName of the route
Returns
boolean
removeDefaultRoutes ( )

Remove all standard default routes.

Parameters
Zend_Controller_Router_Route_InterfaceRoute
Returns
Zend_Controller_Router_Rewrite
removeRoute (   $name)

Remove a route from the route chain.

Parameters
string$nameName of the route
Exceptions
Zend_Controller_Router_Exception
Returns
Zend_Controller_Router_Rewrite
route ( Zend_Controller_Request_Abstract  $request)

Find a matching route to the current PATH_INFO and inject returning values to the Request object.

Exceptions
Zend_Controller_Router_Exception
Returns
Zend_Controller_Request_Abstract Request object

Implements Zend_Controller_Router_Interface.

setChainNameSeparator (   $separator)

Set the separator to use with chain names.

Parameters
string$separatorThe separator to use
Returns
Zend_Controller_Router_Rewrite
setGlobalParam (   $name,
  $value 
)

Set a global parameter.

Parameters
string$name
mixed$value
Returns
Zend_Controller_Router_Rewrite
useRequestParametersAsGlobal (   $use = null)

Determines/returns whether to use the request parameters as global parameters.

Parameters
boolean | null$useNull/unset when you want to retrieve the current state. True when request parameters should be global, false otherwise
Returns
boolean|Zend_Controller_Router_Rewrite Returns a boolean if first param isn't set, returns an instance of Zend_Controller_Router_Rewrite otherwise.

Member Data Documentation

$_chainNameSeparator = '-'
protected
$_currentRoute = null
protected
$_globalParams = array()
protected
$_routes = array()
protected
$_useCurrentParamsAsGlobal = false
protected
$_useDefaultRoutes = true
protected