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.
Simplify context switching based on requested format
TRIGGER_INIT = 'TRIGGER_INIT'
Trigger type constants
TRIGGER_POST = 'TRIGGER_POST'
boolean $_autoJsonSerialization = 'true'
JSON auto-serialization flag
string $_contextKey = 'contexts'
Controller property key to utilize for context switching
string $_contextParam = 'format'
Request parameter containing requested context
array $_contexts = 'array'
Supported contexts
string $_currentContext = ''
Current context
string $_defaultContext = 'xml'
Default context (xml)
boolean $_disableLayout = 'true'
Whether or not to disable layouts when switching contexts
array $_specialConfig = 'array'
Methods that require special configuration
array $_unconfigurable = 'array'
Methods that are not configurable via setOptions and setConfig
Zend_Controller_Action_Helper_ViewRenderer $_viewRenderer = ''
string $_viewSuffixOrig = ''
Original view suffix prior to detecting context switch
__construct(
array|Zend_Config $options
=
null
)
:
void
Constructor
_getViewRenderer(
)
:
Zend_Controller_Action_Helper_ViewRenderer
Retrieve ViewRenderer
_setCallbacks(
array $options
)
:
Zend_Controller_Action_Helper_ContextSwitch
Set callbacks from array of context => callbacks pairs
_setHeaders(
array $options
)
:
Zend_Controller_Action_Helper_ContextSwitch
Set headers from context => headers pairs
_setSuffix(
array $spec
)
:
Zend_Controller_Action_Helper_ContextSwitch
Set suffix from array
_validateTrigger(
string $trigger
)
:
string
Validate trigger and return in normalized form
addActionContext(
string $action, string|array $context
)
:
Zend_Controller_Action_Helper_ContextSwitch|void
Add one or more contexts to an action
addActionContexts(
array $contexts
)
:
Zend_Controller_Action_Helper_ContextSwitch
Add multiple action/context pairs at once
addContext(
string $context, array $spec
)
:
Zend_Controller_Action_Helper_ContextSwitch
Add new context
addContexts(
array $contexts
)
:
Zend_Controller_Action_Helper_ContextSwitch
Add multiple contexts
addHeader(
string $context, string $header, string $content
)
:
Zend_Controller_Action_Helper_ContextSwitch
Add header to context
addHeaders(
string $context, array $headers
)
:
Zend_Controller_Action_Helper_ContextSwitch
Add multiple headers at once for a given context
clearActionContexts(
string $action
=
null
)
:
Zend_Controller_Action_Helper_ContextSwitch
Clear all contexts for a given controller action or all actions
clearCallbacks(
string $context
)
:
Zend_Controller_Action_Helper_ContextSwitch
Clear all callbacks for a given context
clearContexts(
)
:
Zend_Controller_Action_Helper_ContextSwitch
Remove all contexts
clearHeaders(
string $context
)
:
Zend_Controller_Action_Helper_ContextSwitch
Clear all headers for a given context
direct(
)
:
Zend_Controller_Action_Helper_ContextSwitch
Strategy pattern: return object
getActionContexts(
string $action
=
null
)
:
array
Get contexts for a given action or all actions in the controller
getAutoDisableLayout(
)
:
boolean
Retrieve auto layout disable flag
getAutoJsonSerialization(
)
:
boolean
Get JSON context auto-serialization flag
getCallback(
string $context, string $trigger
)
:
string|array|null
Get a single callback for a given context and trigger
getCallbacks(
string $context
)
:
array
Get all callbacks for a given context
getContext(
string $context
)
:
array|null
Retrieve context specification
getContextParam(
)
:
string
Return context format request parameter name
getContexts(
)
:
array
Retrieve context definitions
getCurrentContext(
)
:
null|string
Return current context, if any
getDefaultContext(
)
:
string
Return default context
getHeader(
string $context, string $header
)
:
string|null
Retrieve context header
Returns the value of a given header for a given context type
getHeaders(
string $context
)
:
array
Retrieve context headers
Returns all headers for a context as key/value pairs
getSuffix(
string $type
)
:
string
Retrieve suffix for given context type
hasActionContext(
string $action, string|array $context
)
:
boolean
Does a particular controller action have the given context(s)?
hasContext(
string $context, boolean $throwException
=
false
)
:
bool
Does the given context exist?
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
initJsonContext(
)
:
void
JSON context extra initialization
Turns off viewRenderer auto-rendering
postDispatch(
)
:
void
Post dispatch processing
Execute postDispatch callback for current context, if available
postJsonContext(
)
:
void
JSON post processing
JSON serialize view variables to response body
removeActionContext(
string $action, string|array $context
)
:
boolean
Remove one or more contexts for a given controller action
removeCallback(
string $context, string $trigger
)
:
boolean
Clear a callback for a given context and trigger
removeContext(
string $context
)
:
boolean
Remove a context
removeHeader(
string $context, string $header
)
:
boolean
Remove a single header from a context
setActionContext(
string $action, string|array $context
)
:
Zend_Controller_Action_Helper_ContextSwitch|void
Set a context as available for a given controller action
setActionContexts(
array $contexts
)
:
Zend_Controller_Action_Helper_ContextSwitch
Overwrite and set multiple action contexts at once
setAutoDisableLayout(
boolean $flag
)
:
Zend_Controller_Action_Helper_ContextSwitch
Set flag indicating if layout should be disabled
setAutoJsonSerialization(
boolean $flag
)
:
Zend_Controller_Action_Helper_ContextSwitch
Should JSON contexts auto-serialize?
setCallback(
string $context, string $trigger, string|array $callback
)
:
Zend_Controller_Action_Helper_ContextSwitch
Set a callback for a given context and trigger
setCallbacks(
string $context, array $callbacks
)
:
Zend_Controller_Action_Helper_ContextSwitch
Set callbacks for a given context
Callbacks should be in trigger/callback pairs.
setConfig(
Zend_Config $config
)
:
Zend_Controller_Action_Helper_ContextSwitch
Set object state from config object
setContext(
string $context, array $spec
)
:
Zend_Controller_Action_Helper_ContextSwitch
Overwrite existing context
setContextParam(
string $name
)
:
Zend_Controller_Action_Helper_ContextSwitch
Set name of parameter to use when determining context format
setContexts(
array $contexts
)
:
Zend_Controller_Action_Helper_ContextSwitch
Set multiple contexts, after first removing all
setDefaultContext(
string $type
)
:
Zend_Controller_Action_Helper_ContextSwitch
Indicate default context to use when no context format provided
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.
setHeaders(
string $context, array $headers
)
:
Zend_Controller_Action_Helper_ContextSwitch
Set multiple headers at once for a given context
setOptions(
array $options
)
:
Zend_Controller_Action_Helper_ContextSwitch
Configure object from array of options
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.