Controller/Action/Helper/Redirector.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 license@zend.com 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
- Zend_Controller_Action_Helper
- Version
- $Id$
\Zend_Controller_Action_Helper_Redirector
Package: Zend_Controller\Zend_Controller_Action_Helper- Parent(s)
- \Zend_Controller_Action_Helper_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties
boolean $_closeSessionOnExit = true
Whether or not to close the session before exiting
Default valuetrue
Details- Type
- boolean
int $_code = 302
HTTP status code for redirects
Default value302
Details- Type
- int
boolean $_exit = true
Whether or not calls to _redirect() should exit script execution
Default valuetrue
Details- Type
- boolean
boolean $_prependBase = true
Whether or not _redirect() should attempt to prepend the base URL to the
passed URL (if it's a relative URL)
Default valuetrue
Details- Type
- boolean
boolean $_useAbsoluteUri = false
Whether or not to use an absolute URI when redirecting
Default valuefalse
Details- Type
- boolean
Methods
_checkCode(int $code) : true
Validate HTTP status redirect code
ParametersName | Type | Description |
---|
$code | int | |
---|
ReturnsThrows _prependBase(string $url) : string
Determine if the baseUrl should be prepended, and prepend if necessary
ParametersName | Type | Description |
---|
$url | string | |
---|
Returns direct(string $action, string $controller = null, string $module = null, array $params = array()) : void
direct(): Perform helper when called as
$this->_helper->redirector($action, $controller, $module, $params)
ParametersName | Type | Description |
---|
$action | string | |
---|
$controller | string | |
---|
$module | string | |
---|
$params | array | |
---|
gotoRoute(array $urlOptions = array(), string $name = null, boolean $reset = false, boolean $encode = true) : void
Redirect to a route-based URL
Uses route's assemble method tobuild the URL; route is specified by $name;
default route is used if none provided.
ParametersName | Type | Description |
---|
$urlOptions | array | Array of key/value pairs used to assemble URL |
---|
$name | string | |
---|
$reset | boolean | |
---|
$encode | boolean | |
---|
gotoRouteAndExit(array $urlOptions = array(), string $name = null, boolean $reset = false) : void
Redirect to a route-based URL, and immediately exit
Uses route's assemble method tobuild the URL; route is specified by $name;
default route is used if none provided.
ParametersName | Type | Description |
---|
$urlOptions | array | Array of key/value pairs used to assemble URL |
---|
$name | string | |
---|
$reset | boolean | |
---|
gotoSimple(string $action, string $controller = null, string $module = null, array $params = array()) : void
Perform a redirect to an action/controller/module with params
ParametersName | Type | Description |
---|
$action | string | |
---|
$controller | string | |
---|
$module | string | |
---|
$params | array | |
---|
gotoSimpleAndExit(mixed $action, mixed $controller = null, mixed $module = null, array $params = array()) : void
Perform a redirect to an action/controller/module with params, forcing an immdiate exit
ParametersName | Type | Description |
---|
$action | mixed | |
---|
$controller | mixed | |
---|
$module | mixed | |
---|
$params | array | |
---|
gotoUrl(string $url, array $options = array()) : void
Perform a redirect to a url
ParametersName | Type | Description |
---|
$url | string | |
---|
$options | array | |
---|
gotoUrlAndExit(string $url, array $options = array()) : void
Set a URL string for a redirect, perform redirect, and immediately exit
ParametersName | Type | Description |
---|
$url | string | |
---|
$options | array | |
---|
setCloseSessionOnExit(boolean $flag) : \Zend_Controller_Action_Helper_Redirector
Set flag for whether or not {@link redirectAndExit()} shall close the session before exiting.
ParametersName | Type | Description |
---|
$flag | boolean | |
---|
Returns setGotoRoute(array $urlOptions = array(), string $name = null, boolean $reset = false, boolean $encode = true) : void
Build a URL based on a route
ParametersName | Type | Description |
---|
$urlOptions | array | |
---|
$name | string | Route name |
---|
$reset | boolean | |
---|
$encode | boolean | |
---|
setGotoSimple(string $action, string $controller = null, string $module = null, array $params = array()) : void
Set a redirect URL of the form /module/controller/action/params
ParametersName | Type | Description |
---|
$action | string | |
---|
$controller | string | |
---|
$module | string | |
---|
$params | array | |
---|
setGotoUrl(string $url, array $options = array()) : void
Set a redirect URL string
By default, emits a 302 HTTP status header, prepends base URL as defined
in request object if url is relative, and halts script execution by
calling exit().
$options is an optional associative array that can be used to control
redirect behaviour. The available option keys are:
- exit: boolean flag indicating whether or not to halt script execution when done
- prependBase: boolean flag indicating whether or not to prepend the base URL when a relative URL is provided
- code: integer HTTP status code to use with redirect. Should be between 300 and 307.
_redirect() sets the Location header in the response object. If you set
the exit flag to false, you can override this header later in code
execution.
If the exit flag is true (true by default), _redirect() will write and
close the current session, if any.
ParametersName | Type | Description |
---|
$url | string | |
---|
$options | array | |
---|