Controller/Action/Helper/ContextSwitch.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_ContextSwitch
Package: Zend_Controller\Zend_Controller_Action_HelperSimplify context switching based on requested format
- Parent(s)
- \Zend_Controller_Action_Helper_Abstract
- Children
- \Zend_Controller_Action_Helper_AjaxContext
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Uses
-
Constants


TRIGGER_POST
= 'TRIGGER_POST'
Properties



boolean $_autoJsonSerialization = true
JSON auto-serialization flag
Default valuetrue
Details- Type
- boolean



string $_contextKey = 'contexts'
Controller property key to utilize for context switching
Default value'contexts'
Details- Type
- string



string $_contextParam = 'format'
Request parameter containing requested context
Default value'format'
Details- Type
- string



boolean $_disableLayout = true
Whether or not to disable layouts when switching contexts
Default valuetrue
Details- Type
- boolean



array $_specialConfig = array('setSuffix', 'setHeaders', 'setCallbacks')
Methods that require special configuration
Default valuearray('setSuffix', 'setHeaders', 'setCallbacks')
Details- Type
- array



array $_unconfigurable = array('setOptions', 'setConfig', 'setHeader', 'setCallback', 'setContext', 'setActionContext', 'setActionContexts')
Methods that are not configurable via setOptions and setConfig
Default valuearray('setOptions', 'setConfig', 'setHeader', 'setCallback', 'setContext', 'setActionContext', 'setActionContexts')
Details- Type
- array
Methods



_validateTrigger(string $trigger) : string
Validate trigger and return in normalized form
ParametersName | Type | Description |
---|
$trigger | string | |
---|
ReturnsThrows 


getActionContexts(string $action = null) : array
Get contexts for a given action or all actions in the controller
ParametersName | Type | Description |
---|
$action | string | |
---|
Returns 


getCallback(string $context, string $trigger) : string | array | null
Get a single callback for a given context and trigger
ParametersName | Type | Description |
---|
$context | string | |
---|
$trigger | string | |
---|
ReturnsType | Description |
---|
string | array | null | |



getCallbacks(string $context) : array
Get all callbacks for a given context
ParametersName | Type | Description |
---|
$context | string | |
---|
Returns 


getContext(string $context) : array | null
Retrieve context specification
ParametersName | Type | Description |
---|
$context | string | |
---|
ReturnsType | Description |
---|
array | null | |



getCurrentContext() : null | string
Return current context, if any
ReturnsType | Description |
---|
null | string | |



getSuffix(string $type) : string
Retrieve suffix for given context type
ParametersName | Type | Description |
---|
$type | string | Context type |
---|
ReturnsThrows 


hasActionContext(string $action, string | array $context) : boolean
Does a particular controller action have the given context(s)?
ParametersName | Type | Description |
---|
$action | string | |
---|
$context | string | array | |
---|
ReturnsThrows 


hasContext(string $context, boolean $throwException = false) : bool
Does the given context exist?
ParametersName | Type | Description |
---|
$context | string | |
---|
$throwException | boolean | |
---|
ReturnsThrows 


init() : void
Initialize at start of action controller
Reset the view script suffix to the original state, or store the
original state.



initContext(mixed $format = null) : void
Initialize context detection and switching
ParametersName | Type | Description |
---|
$format | mixed | |
---|
Throws 


initJsonContext() : void
JSON context extra initialization
Turns off viewRenderer auto-rendering



removeActionContext(string $action, string | array $context) : boolean
Remove one or more contexts for a given controller action
ParametersName | Type | Description |
---|
$action | string | |
---|
$context | string | array | |
---|
Returns 


removeCallback(string $context, string $trigger) : boolean
Clear a callback for a given context and trigger
ParametersName | Type | Description |
---|
$context | string | |
---|
$trigger | string | |
---|
Returns 


removeHeader(string $context, string $header) : boolean
Remove a single header from a context
ParametersName | Type | Description |
---|
$context | string | |
---|
$header | string | |
---|
Returns 


setActionContext(string $action, string | array $context) : \Zend_Controller_Action_Helper_ContextSwitch | void
Set a context as available for a given controller action
ParametersName | Type | Description |
---|
$action | string | |
---|
$context | string | array | |
---|
Returns 


setCallback(string $context, string $trigger, string | array $callback) : \Zend_Controller_Action_Helper_ContextSwitch
Set a callback for a given context and trigger
ParametersName | Type | Description |
---|
$context | string | |
---|
$trigger | string | |
---|
$callback | string | array | |
---|
ReturnsThrows 


setCallbacks(string $context, array $callbacks) : \Zend_Controller_Action_Helper_ContextSwitch
Set callbacks for a given context
Callbacks should be in trigger/callback pairs.
ParametersName | Type | Description |
---|
$context | string | |
---|
$callbacks | array | |
---|
Returns


setHeader( $context, string $header, string $content) : \Zend_Controller_Action_Helper_ContextSwitch
Customize response header to use when switching context
Passing an empty header value to the setters disables the response
header.
ParametersName | Type | Description |
---|
$context | | |
---|
$header | string | Header to set |
---|
$content | string | Header content |
---|
Returns


setSuffix(string $context, string $suffix, boolean $prependViewRendererSuffix = true) : \Zend_Controller_Action_Helper_ContextSwitch
Customize view script suffix to use when switching context.
Passing an empty suffix value to the setters disables the view script
suffix change.
ParametersName | Type | Description |
---|
$context | string | Context type for which to set suffix |
---|
$suffix | string | Suffix to use |
---|
$prependViewRendererSuffix | boolean | Whether or not to prepend the new suffix to the viewrenderer suffix |
---|
ReturnsThrows