Controller/Router/Rewrite.php
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
[email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Controller
- Subpackage
- Router
- Version
- $Id$
\Zend_Controller_Router_Rewrite
Package: Zend_Controller\RouterRuby routing based Router.
- Parent(s)
- \Zend_Controller_Router_Abstract
- See
-
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties
string $_chainNameSeparator = '-'
Separator to use with chain names
Default value'-'
Details- Type
- string
array $_globalParams = array()
Global parameters given to all routes
Default valuearray()
Details- Type
- array
array $_routes = array()
Array of routes to match against
Default valuearray()
Details- Type
- array
boolean $_useCurrentParamsAsGlobal = false
Determines if request parameters should be used as global parameters
inside this router.
Default valuefalse
Details- Type
- boolean
boolean $_useDefaultRoutes = true
Whether or not to use default routes
Default valuetrue
Details- Type
- boolean
Methods
addConfig(\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');
ParametersName | Type | Description |
---|
$config | \Zend_Config | Configuration object |
---|
$section | string | Name of the config section containing route's definitions |
---|
ReturnsThrowsaddRoutes(array $routes) : \Zend_Controller_Router_Rewrite
Add routes to the route chain
ParametersName | Type | Description |
---|
$routes | array | Array of routes with names as keys and routes as values |
---|
Returns assemble(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.
ParametersName | Type | Description |
---|
$userParams | array | Options passed by a user used to override parameters |
---|
$name | mixed | The name of a Route to use |
---|
$reset | bool | Whether to reset to the route defaults ignoring URL params |
---|
$encode | bool | Tells to encode URL parts on output |
---|
ReturnsType | Description |
---|
string | Resulting absolute URL path |
Throws getRoutes() : array
Retrieve an array of routes added to the route chain
ReturnsType | Description |
---|
array | All of the defined routes |
hasRoute(string $name) : boolean
Check if named route exists
ParametersName | Type | Description |
---|
$name | string | Name of the route |
---|
Returns removeRoute(string $name) : \Zend_Controller_Router_Rewrite
Remove a route from the route chain
ParametersName | Type | Description |
---|
$name | string | Name of the route |
---|
ReturnsThrows route( $request) : \Zend_Controller_Request_Abstract
Find a matching route to the current PATH_INFO and inject
returning values to the Request object.
ParametersName | Type | Description |
---|
$request | | |
---|
ReturnsThrows setChainNameSeparator(string $separator) : \Zend_Controller_Router_Rewrite
Set the separator to use with chain names
ParametersName | Type | Description |
---|
$separator | string | The separator to use |
---|
Returns useRequestParametersAsGlobal(boolean | null $use = null) : boolean | \Zend_Controller_Router_Rewrite
Determines/returns whether to use the request parameters as global parameters.
ParametersName | Type | Description |
---|
$use | boolean | null | Null/unset when you want to retrieve the current state.
True when request parameters should be global, false otherwise
|
---|
ReturnsType | Description |
---|
boolean | \Zend_Controller_Router_Rewrite | Returns a boolean if first param isn't set, returns an
instance of Zend_Controller_Router_Rewrite otherwise. |