Controller/Router/Rewrite.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Controller  
Subpackage
Router  
Version
$Id: Rewrite.php 24593 2012-01-05 20:35:02Z matthew $  

\Zend_Controller_Router_Rewrite

Package: Zend\Controller\Router
Ruby routing based Router.
Parent(s)
\Zend_Controller_Router_Abstract
See
\global\http://manuals.rubyonrails.com/read/chapter/65  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  URI_DELIMITER = '/'
inherited
URI delimiter
Inherited from: \Zend_Controller_Router_Abstract::URI_DELIMITER

Properties

>VPropertyprotectedstring $_chainNameSeparator = '-'
Separator to use with chain names
Default value'-'Details
Type
string
>VPropertyprotected\Zend_Controller_Router_Route_Interface $_currentRoute = null
Currently matched route
Default valuenullDetails
Type
\Zend_Controller_Router_Route_Interface
>VPropertyprotected\Zend_Controller_Front $_frontController
inherited
Front controller instance
Inherited from: \Zend_Controller_Router_Abstract::$$_frontController
>VPropertyprotectedarray $_globalParams = array()
Global parameters given to all routes
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_invokeParams = array()
inherited
Array of invocation parameters to use when instantiating action controllers
Inherited from: \Zend_Controller_Router_Abstract::$$_invokeParams
Default valuearray()Details
Type
array
Inherited_from
\Zend_Controller_Router_Abstract::$$_invokeParams  
>VPropertyprotectedarray $_routes = array()
Array of routes to match against
Default valuearray()Details
Type
array
>VPropertyprotectedboolean $_useCurrentParamsAsGlobal = false
Determines if request parameters should be used as global parameters inside this router.
Default valuefalseDetails
Type
boolean
>VPropertyprotectedboolean $_useDefaultRoutes = true
Whether or not to use default routes
Default valuetrueDetails
Type
boolean

Methods

methodpublic__construct(array $params = array()) : void
inherited

Constructor

Inherited from: \Zend_Controller_Router_Abstract::__construct()
Parameters
NameTypeDescription
$paramsarray
methodprotected_addChainRoutesFromConfig(string $name, \Zend_Controller_Router_Route_Interface $route, \Zend_Config $childRoutesInfo) : void

Add chain routes from a config route

Parameters
NameTypeDescription
$namestring
$route\Zend_Controller_Router_Route_Interface
$childRoutesInfo\Zend_Config
methodprotected_getRouteFromConfig(\Zend_Config $info) : \Zend_Controller_Router_Route_Interface

Get a route frm a config instance

Parameters
NameTypeDescription
$info\Zend_Config
Returns
TypeDescription
\Zend_Controller_Router_Route_Interface
methodprotected_setRequestParams( $request,  $params) : void

Parameters
NameTypeDescription
$request
$params
methodpublicaddConfig(\Zend_Config $config, string $section = null) : \Zend_Controller_Router_Rewrite

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
NameTypeDescription
$config\Zend_Config

Configuration object

$sectionstring

Name of the config section containing route's definitions

Returns
TypeDescription
\Zend_Controller_Router_Rewrite
Throws
ExceptionDescription
\Zend_Controller_Router_Exception
methodpublicaddDefaultRoutes() : \Zend_Controller_Router_Rewrite

Add default routes which are used to mimic basic router behaviour

Returns
TypeDescription
\Zend_Controller_Router_Rewrite
methodpublicaddRoute(string $name, \Zend_Controller_Router_Route_Interface $route) : \Zend_Controller_Router_Rewrite

Add route to the route chain

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

Parameters
NameTypeDescription
$namestring

Name of the route

$route\Zend_Controller_Router_Route_Interface

Instance of the route

Returns
TypeDescription
\Zend_Controller_Router_Rewrite
methodpublicaddRoutes(array $routes) : \Zend_Controller_Router_Rewrite

Add routes to the route chain

Parameters
NameTypeDescription
$routesarray

Array of routes with names as keys and routes as values

Returns
TypeDescription
\Zend_Controller_Router_Rewrite
methodpublicassemble(array $userParams, mixed $name = null, bool $reset = false, bool $encode = true) : string

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

May be passed user params to override ones from URI, Request or even defaults. If passed parameter has a value of null, it's URL variable will be reset to default.

If null is passed as a route name assemble will use the current Route or 'default' if current is not yet set.

Reset is used to signal that all parameters should be reset to it's defaults. Ignoring all URL specified values. User specified params still get precedence.

Encode tells to url encode resulting path parts.

Parameters
NameTypeDescription
$userParamsarray

Options passed by a user used to override parameters

$namemixed

The name of a Route to use

$resetbool

Whether to reset to the route defaults ignoring URL params

$encodebool

Tells to encode URL parts on output

Returns
TypeDescription
stringResulting absolute URL path
Throws
ExceptionDescription
\Zend_Controller_Router_Exception
methodpublicclearParams(null | string | array $name = null) : \Zend_Controller_Router
inherited

Clear the controller parameter stack

Inherited from: \Zend_Controller_Router_Abstract::clearParams()

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.

Parameters
NameTypeDescription
$namenull | string | array

single key or array of keys for params to clear

Returns
TypeDescription
\Zend_Controller_Router
methodpublicgetChainNameSeparator() : string

Get the separator to use for chain names

Returns
TypeDescription
string
methodpublicgetCurrentRoute() : \Zend_Controller_Router_Route_Interface

Retrieve a currently matched route

Returns
TypeDescription
\Zend_Controller_Router_Route_InterfaceRoute object
Throws
ExceptionDescription
\Zend_Controller_Router_Exception
methodpublicgetCurrentRouteName() : \Zend_Controller_Router_Route_Interface

Retrieve a name of currently matched route

Returns
TypeDescription
\Zend_Controller_Router_Route_InterfaceRoute object
Throws
ExceptionDescription
\Zend_Controller_Router_Exception
methodpublicgetFrontController() : \Zend_Controller_Front
inherited

Retrieve Front Controller

Inherited from: \Zend_Controller_Router_Abstract::getFrontController()
Returns
TypeDescription
\Zend_Controller_Front
methodpublicgetParam(string $name) : mixed
inherited

Retrieve a single parameter from the controller parameter stack

Inherited from: \Zend_Controller_Router_Abstract::getParam()
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
mixed
methodpublicgetParams() : array
inherited

Retrieve action controller instantiation parameters

Inherited from: \Zend_Controller_Router_Abstract::getParams()
Returns
TypeDescription
array
methodpublicgetRoute(string $name) : \Zend_Controller_Router_Route_Interface

Retrieve a named route

Parameters
NameTypeDescription
$namestring

Name of the route

Returns
TypeDescription
\Zend_Controller_Router_Route_InterfaceRoute object
Throws
ExceptionDescription
\Zend_Controller_Router_Exception
methodpublicgetRoutes() : array

Retrieve an array of routes added to the route chain

Returns
TypeDescription
arrayAll of the defined routes
methodpublichasRoute(string $name) : boolean

Check if named route exists

Parameters
NameTypeDescription
$namestring

Name of the route

Returns
TypeDescription
boolean
methodpublicremoveDefaultRoutes() : \Zend_Controller_Router_Rewrite

Remove all standard default routes

Returns
TypeDescription
\Zend_Controller_Router_Rewrite
methodpublicremoveRoute(string $name) : \Zend_Controller_Router_Rewrite

Remove a route from the route chain

Parameters
NameTypeDescription
$namestring

Name of the route

Returns
TypeDescription
\Zend_Controller_Router_Rewrite
Throws
ExceptionDescription
\Zend_Controller_Router_Exception
methodpublicroute( $request) : \Zend_Controller_Request_Abstract

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

If no route was possible, an exception is thrown.

Parameters
NameTypeDescription
$request
Returns
TypeDescription
\Zend_Controller_Request_AbstractRequest object
Throws
ExceptionDescription
\Zend_Controller_Router_Exception
methodpublicsetChainNameSeparator(string $separator) : \Zend_Controller_Router_Rewrite

Set the separator to use with chain names

Parameters
NameTypeDescription
$separatorstring

The separator to use

Returns
TypeDescription
\Zend_Controller_Router_Rewrite
methodpublicsetFrontController(\Zend_Controller_Front $controller) : \Zend_Controller_Router_Interface
inherited

Set Front Controller

Inherited from: \Zend_Controller_Router_Abstract::setFrontController()
Parameters
NameTypeDescription
$controller\Zend_Controller_Front
Returns
TypeDescription
\Zend_Controller_Router_Interface
methodpublicsetGlobalParam(string $name, mixed $value) : \Zend_Controller_Router_Rewrite

Set a global parameter

Parameters
NameTypeDescription
$namestring
$valuemixed
Returns
TypeDescription
\Zend_Controller_Router_Rewrite
methodpublicsetParam(string $name, mixed $value) : \Zend_Controller_Router
inherited

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

Inherited from: \Zend_Controller_Router_Abstract::setParam()
Parameters
NameTypeDescription
$namestring
$valuemixed
Returns
TypeDescription
\Zend_Controller_Router
methodpublicsetParams(array $params) : \Zend_Controller_Router
inherited

Set parameters to pass to action controller constructors

Inherited from: \Zend_Controller_Router_Abstract::setParams()
Parameters
NameTypeDescription
$paramsarray
Returns
TypeDescription
\Zend_Controller_Router
methodpublicuseRequestParametersAsGlobal(boolean | null $use = null) : boolean | \Zend_Controller_Router_Rewrite

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

Parameters
NameTypeDescription
$useboolean | null

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

Returns
TypeDescription
boolean | \Zend_Controller_Router_RewriteReturns a boolean if first param isn't set, returns an instance of Zend_Controller_Router_Rewrite otherwise.
Documentation was generated by phpDocumentor 2.0.0a12.