API Documentation

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-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Controller  
subpackage
Zend_Controller_Action_Helper  
version
$Id: Redirector.php 23940 2011-05-02 20:20:40Z matthew $  

\Zend_Controller_Action_Helper_Redirector

Extends from
\Zend_Controller_Action_Helper_Abstract
category
Zend  
copyright
Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Controller  
subpackage
Zend_Controller_Action_Helper  

Properties

Propertyprotectedboolean  $_closeSessionOnExit= 'true'

Whether or not to close the session before exiting

Default valuetrueDetails
Type
boolean
Propertyprotectedint  $_code= '302'

HTTP status code for redirects

Default value302Details
Type
int
Propertyprotectedboolean  $_exit= 'true'

Whether or not calls to _redirect() should exit script execution

Default valuetrueDetails
Type
boolean
Propertyprotectedboolean  $_prependBase= 'true'

Whether or not _redirect() should attempt to prepend the base URL to the passed URL (if it's a relative URL)

Default valuetrueDetails
Type
boolean
Propertyprotectedstring  $_redirectUrl= 'null'

Url to which to redirect

Default valuenullDetails
Type
string
Propertyprotectedboolean  $_useAbsoluteUri= 'false'

Whether or not to use an absolute URI when redirecting

Default valuefalseDetails
Type
boolean

Methods

methodpublic__call( string $method, array $args ) : mixed

Overloading

Overloading for old 'goto', 'setGoto', and 'gotoAndExit' methods

Parameters
Name Type Description
$method string
$args array
Returns
Type Description
mixed
Throws
Exception Description
\Zend_Controller_Action_Exception for invalid methods
methodprotected_checkCode( int $code ) : true

Validate HTTP status redirect code

Parameters
Name Type Description
$code int
Returns
Type Description
true
Throws
Exception Description
\Zend_Controller_Action_Exception on invalid HTTP status code
methodprotected_prependBase( string $url ) : string

Determine if the baseUrl should be prepended, and prepend if necessary

Parameters
Name Type Description
$url string
Returns
Type Description
string
methodprotected_redirect(  $url ) : void

Set redirect in response object

Parameters
Name Type Description
$url
methodpublicdirect( 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)

Parameters
Name Type Description
$action string
$controller string
$module string
$params array
methodpublicgetActionController( ) : \Zend_Controller_Action

Retrieve current action controller

Inherited from: \Zend_Controller_Action_Helper_Abstract::getActionController()
Returns
Type Description
\Zend_Controller_Action
methodpublicgetCloseSessionOnExit( ) : boolean

Retrieve flag for whether or not {@link redirectAndExit()} shall close the session before exiting.

Returns
Type Description
boolean
methodpublicgetCode( ) : int

Retrieve HTTP status code to emit on {@link _redirect()} call

Returns
Type Description
int
methodpublicgetExit( ) : boolean

Retrieve flag for whether or not {@link _redirect()} will exit when finished.

Returns
Type Description
boolean
methodpublicgetFrontController( ) : \Zend_Controller_Front

Retrieve front controller instance

Inherited from: \Zend_Controller_Action_Helper_Abstract::getFrontController()
Returns
Type Description
\Zend_Controller_Front
methodpublicgetName( ) : string
Returns
Type Description
string
methodpublicgetPrependBase( ) : boolean

Retrieve flag for whether or not {@link _redirect()} will prepend the base URL on relative URLs

Returns
Type Description
boolean
methodpublicgetRedirectUrl( ) : string

Retrieve currently set URL for redirect

Returns
Type Description
string
methodpublicgetRequest( ) : \Zend_Controller_Request_Abstract
Returns
Type Description
\Zend_Controller_Request_Abstract $request
methodpublicgetResponse( ) : \Zend_Controller_Response_Abstract
Returns
Type Description
\Zend_Controller_Response_Abstract $response
methodpublicgetUseAbsoluteUri( ) : boolean

Return use absolute URI flag

Returns
Type Description
boolean
methodpublicgotoRoute( 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.

Parameters
Name Type Description
$urlOptions array

Array of key/value pairs used to assemble URL

$name string
$reset boolean
$encode boolean
methodpublicgotoRouteAndExit( 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.

Parameters
Name Type Description
$urlOptions array

Array of key/value pairs used to assemble URL

$name string
$reset boolean
methodpublicgotoSimple( string $action, string $controller = null, string $module = null, array $params = array ) : void

Perform a redirect to an action/controller/module with params

Parameters
Name Type Description
$action string
$controller string
$module string
$params array
methodpublicgotoSimpleAndExit( 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

Parameters
Name Type Description
$action mixed
$controller mixed
$module mixed
$params array
methodpublicgotoUrl( string $url, array $options = array ) : void

Perform a redirect to a url

Parameters
Name Type Description
$url string
$options array
methodpublicgotoUrlAndExit( string $url, array $options = array ) : void

Set a URL string for a redirect, perform redirect, and immediately exit

Parameters
Name Type Description
$url string
$options array
methodpublicinit( ) : void

Hook into action controller initialization

Inherited from: \Zend_Controller_Action_Helper_Abstract::init()
methodpublicpostDispatch( ) : void

Hook into action controller postDispatch() workflow

Inherited from: \Zend_Controller_Action_Helper_Abstract::postDispatch()
methodpublicpreDispatch( ) : void

Hook into action controller preDispatch() workflow

Inherited from: \Zend_Controller_Action_Helper_Abstract::preDispatch()
methodpublicredirectAndExit( ) : void

exit(): Perform exit for redirector

methodpublicsetActionController( \Zend_Controller_Action $actionController = null ) : \Zend_Controller_ActionHelper_Abstract
Parameters
Name Type Description
$actionController \Zend_Controller_Action
Returns
Type Description
\Zend_Controller_ActionHelper_Abstract Provides a fluent interface
methodpublicsetCloseSessionOnExit( boolean $flag ) : \Zend_Controller_Action_Helper_Redirector

Set flag for whether or not {@link redirectAndExit()} shall close the session before exiting.

Parameters
Name Type Description
$flag boolean
Returns
Type Description
\Zend_Controller_Action_Helper_Redirector Provides a fluent interface
methodpublicsetCode( int $code ) : \Zend_Controller_Action_Helper_Redirector

Retrieve HTTP status code for {@link _redirect()} behaviour

Parameters
Name Type Description
$code int
Returns
Type Description
\Zend_Controller_Action_Helper_Redirector Provides a fluent interface
methodpublicsetExit( boolean $flag ) : \Zend_Controller_Action_Helper_Redirector

Retrieve exit flag for {@link _redirect()} behaviour

Parameters
Name Type Description
$flag boolean
Returns
Type Description
\Zend_Controller_Action_Helper_Redirector Provides a fluent interface
methodpublicsetGotoRoute( array $urlOptions = array, string $name = null, boolean $reset = false, boolean $encode = true ) : void

Build a URL based on a route

Parameters
Name Type Description
$urlOptions array
$name string Route name
$reset boolean
$encode boolean
methodpublicsetGotoSimple( string $action, string $controller = null, string $module = null, array $params = array ) : void

Set a redirect URL of the form /module/controller/action/params

Parameters
Name Type Description
$action string
$controller string
$module string
$params array
methodpublicsetGotoUrl( 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.

Parameters
Name Type Description
$url string
$options array
methodpublicsetPrependBase( boolean $flag ) : \Zend_Controller_Action_Helper_Redirector

Retrieve 'prepend base' flag for {@link _redirect()} behaviour

Parameters
Name Type Description
$flag boolean
Returns
Type Description
\Zend_Controller_Action_Helper_Redirector Provides a fluent interface
methodpublicsetUseAbsoluteUri( boolean $flag = true ) : \Zend_Controller_Action_Helper_Redirector

Set use absolute URI flag

Parameters
Name Type Description
$flag boolean
Returns
Type Description
\Zend_Controller_Action_Helper_Redirector Provides a fluent interface
Documentation was generated by DocBlox 0.13.3.