Ruby routing based Router.

package Zend_Controller
subpackage Router
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
see
inherited_from \Zend_Controller_Router_Abstract

 Methods

Constructor

__construct(array $params = array()
Inherited

Parameters

$params

array

Create routes out of Zend_Config configuration

addConfig(\Zend_Config $config, string $section = null) : \Zend_Controller_Router_Rewrite

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

$config

\Zend_Config

Configuration object

$section

string

Name of the config section containing route's definitions

Exceptions

\Zend_Controller_Router_Exception

Returns

\Zend_Controller_Router_Rewrite

Add default routes which are used to mimic basic router behaviour

addDefaultRoutes() : \Zend_Controller_Router_Rewrite

Returns

\Zend_Controller_Router_Rewrite

Add route to the route chain

addRoute(string $name, \Zend_Controller_Router_Route_Interface $route) : \Zend_Controller_Router_Rewrite

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

Parameters

$name

string

Name of the route

$route

\Zend_Controller_Router_Route_Interface

Instance of the route

Returns

\Zend_Controller_Router_Rewrite

Add routes to the route chain

addRoutes(array $routes) : \Zend_Controller_Router_Rewrite

Parameters

$routes

array

Array of routes with names as keys and routes as values

Returns

\Zend_Controller_Router_Rewrite

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

assemble(array $userParams, mixed $name = null, boolean $reset = false, boolean $encode = true) : string

Parameters

$userParams

array

Options passed by a user used to override parameters

$name

mixed

The name of a Route to use

$reset

boolean

Whether to reset to the route defaults ignoring URL params

$encode

boolean

Tells to encode URL parts on output

Exceptions

\Zend_Controller_Router_Exception

Returns

stringResulting absolute URL path

Clear the controller parameter stack

clearParams($name = null) : \Zend_Controller_Router_Abstract
Inherited

By default, clears all parameters. If a parameter name is given, clears only that parameter; if an array of parameter names is provided, clears each.

inherited_from \Zend_Controller_Router_Interface::clearParams()

Parameters

$name

Returns

\Zend_Controller_Router_Abstract

Get the separator to use for chain names

getChainNameSeparator() : string

Returns

string

Retrieve a currently matched route

getCurrentRoute() : \Zend_Controller_Router_Route_Interface

Exceptions

\Zend_Controller_Router_Exception

Returns

\Zend_Controller_Router_Route_InterfaceRoute object

Retrieve a name of currently matched route

getCurrentRouteName() : string

Exceptions

\Zend_Controller_Router_Exception

Returns

stringRoute name

Retrieve Front Controller

getFrontController() : \Zend_Controller_Front
Inherited
inherited_from \Zend_Controller_Router_Interface::getFrontController()

Returns

\Zend_Controller_Front

Retrieve a single parameter from the controller parameter stack

getParam(string $name) : mixed
Inherited
inherited_from \Zend_Controller_Router_Interface::getParam()

Parameters

$name

string

Returns

mixed

Retrieve action controller instantiation parameters

getParams() : array
Inherited
inherited_from \Zend_Controller_Router_Interface::getParams()

Returns

array

Retrieve a named route

getRoute(string $name) : \Zend_Controller_Router_Route_Interface

Parameters

$name

string

Name of the route

Exceptions

\Zend_Controller_Router_Exception

Returns

\Zend_Controller_Router_Route_InterfaceRoute object

Retrieve an array of routes added to the route chain

getRoutes() : array

Returns

arrayAll of the defined routes

Check if named route exists

hasRoute(string $name) : boolean

Parameters

$name

string

Name of the route

Returns

boolean

Remove all standard default routes

removeDefaultRoutes() : \Zend_Controller_Router_Rewrite

Returns

\Zend_Controller_Router_Rewrite

Remove a route from the route chain

removeRoute(string $name) : \Zend_Controller_Router_Rewrite

Parameters

$name

string

Name of the route

Exceptions

\Zend_Controller_Router_Exception

Returns

\Zend_Controller_Router_Rewrite

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

route(\Zend_Controller_Request_Abstract $request) : \Zend_Controller_Request_Abstract

Parameters

$request

\Zend_Controller_Request_Abstract

Exceptions

\Zend_Controller_Router_Exception

Returns

\Zend_Controller_Request_AbstractRequest object

Set the separator to use with chain names

setChainNameSeparator(string $separator) : \Zend_Controller_Router_Rewrite

Parameters

$separator

string

The separator to use

Returns

\Zend_Controller_Router_Rewrite

Set Front Controller

setFrontController(\Zend_Controller_Front $controller) : \Zend_Controller_Router_Interface
Inherited
inherited_from \Zend_Controller_Router_Interface::setFrontController()

Parameters

$controller

\Zend_Controller_Front

Returns

\Zend_Controller_Router_Interface

Set a global parameter

setGlobalParam(string $name, mixed $value) : \Zend_Controller_Router_Rewrite

Parameters

$name

string

$value

mixed

Returns

\Zend_Controller_Router_Rewrite

Add or modify a parameter to use when instantiating an action controller

setParam(string $name, mixed $value) : \Zend_Controller_Router_Abstract
Inherited
inherited_from \Zend_Controller_Router_Interface::setParam()

Parameters

$name

string

$value

mixed

Returns

\Zend_Controller_Router_Abstract

Set parameters to pass to action controller constructors

setParams(array $params) : \Zend_Controller_Router_Abstract
Inherited
inherited_from \Zend_Controller_Router_Interface::setParams()

Parameters

$params

array

Returns

\Zend_Controller_Router_Abstract

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

useRequestParametersAsGlobal(boolean|null $use = null) : boolean | \Zend_Controller_Router_Rewrite

Parameters

$use

booleannull

Null/unset when you want to retrieve the current state. True when request parameters should be global, false otherwise

Returns

boolean\Zend_Controller_Router_RewriteReturns a boolean if first param isn't set, returns an instance of Zend_Controller_Router_Rewrite otherwise.

Add chain routes from a config route

_addChainRoutesFromConfig(string $name, \Zend_Controller_Router_Route_Interface $route, \Zend_Config $childRoutesInfo) : void

Parameters

$name

string

$route

\Zend_Controller_Router_Route_Interface

$childRoutesInfo

\Zend_Config

Get a route frm a config instance

_getRouteFromConfig(\Zend_Config $info) : \Zend_Controller_Router_Route_Interface

Parameters

$info

\Zend_Config

Returns

\Zend_Controller_Router_Route_Interface

Sets parameters for request object

_setRequestParams(\Zend_Controller_Request_Abstract $request, array $params) 

Module name, controller name and action name

Parameters

$request

\Zend_Controller_Request_Abstract

$params

array

 Properties

 

Separator to use with chain names

$_chainNameSeparator : string

Default

'-'
 

Currently matched route

$_currentRoute : string

Default

null
 

Front controller instance

$_frontController : \Zend_Controller_Front

Default

 

Global parameters given to all routes

$_globalParams : array

Default

array()
 

Array of invocation parameters to use when instantiating action controllers

$_invokeParams : array

Default

array()
 

Array of routes to match against

$_routes : array

Default

array()
 

Determines if request parameters should be used as global parameters inside this router.

$_useCurrentParamsAsGlobal : boolean

Default

false
 

Whether or not to use default routes

$_useDefaultRoutes : boolean

Default

true

 Constants

 

URI delimiter

URI_DELIMITER = '/'