Controller/Action/Helper/ContextSwitch.php
- 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
- 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
Properties
boolean $_autoJsonSerialization = true
true
Details- Type
- boolean
string $_contextKey = 'contexts'
'contexts'
Details- Type
- string
string $_contextParam = 'format'
'format'
Details- Type
- string
boolean $_disableLayout = true
true
Details- Type
- boolean
array $_specialConfig = array('setSuffix', 'setHeaders', 'setCallbacks')
array('setSuffix', 'setHeaders', 'setCallbacks')
Details- Type
- array
array $_unconfigurable = array('setOptions', 'setConfig', 'setHeader', 'setCallback', 'setContext', 'setActionContext', 'setActionContexts')
array('setOptions', 'setConfig', 'setHeader', 'setCallback', 'setContext', 'setActionContext', 'setActionContexts')
Details- Type
- array
Methods
__construct(array | \Zend_Config $options = null) : void
Constructor
Name | Type | Description |
---|---|---|
$options | array | \Zend_Config |
_getViewRenderer() : \Zend_Controller_Action_Helper_ViewRenderer
Retrieve ViewRenderer
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ViewRenderer | Provides a fluent interface |
_setCallbacks(array $options) : \Zend_Controller_Action_Helper_ContextSwitch
Set callbacks from array of context => callbacks pairs
Name | Type | Description |
---|---|---|
$options | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
_setHeaders(array $options) : \Zend_Controller_Action_Helper_ContextSwitch
Set headers from context => headers pairs
Name | Type | Description |
---|---|---|
$options | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
_setSuffix(array $spec) : \Zend_Controller_Action_Helper_ContextSwitch
Set suffix from array
Name | Type | Description |
---|---|---|
$spec | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
_validateTrigger(string $trigger) : string
Validate trigger and return in normalized form
Name | Type | Description |
---|---|---|
$trigger | string |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Controller_Action_Exception |
addActionContext(string $action, string | array $context) : \Zend_Controller_Action_Helper_ContextSwitch | void
Add one or more contexts to an action
Name | Type | Description |
---|---|---|
$action | string | |
$context | string | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | void | Provides a fluent interface |
addActionContexts(array $contexts) : \Zend_Controller_Action_Helper_ContextSwitch
Add multiple action/context pairs at once
Name | Type | Description |
---|---|---|
$contexts | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
addContext(string $context, array $spec) : \Zend_Controller_Action_Helper_ContextSwitch
Add new context
Name | Type | Description |
---|---|---|
$context | string | Context type |
$spec | array | Context specification |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
Exception | Description |
---|---|
\Zend_Controller_Action_Exception |
addContexts(array $contexts) : \Zend_Controller_Action_Helper_ContextSwitch
Add multiple contexts
Name | Type | Description |
---|---|---|
$contexts | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
addHeader(string $context, string $header, string $content) : \Zend_Controller_Action_Helper_ContextSwitch
Add header to context
Name | Type | Description |
---|---|---|
$context | string | |
$header | string | |
$content | string |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
Exception | Description |
---|---|
\Zend_Controller_Action_Exception |
addHeaders(string $context, array $headers) : \Zend_Controller_Action_Helper_ContextSwitch
Add multiple headers at once for a given context
Name | Type | Description |
---|---|---|
$context | string | |
$headers | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
clearActionContexts(string $action = null) : \Zend_Controller_Action_Helper_ContextSwitch
Clear all contexts for a given controller action or all actions
Name | Type | Description |
---|---|---|
$action | string |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
clearCallbacks(string $context) : \Zend_Controller_Action_Helper_ContextSwitch
Clear all callbacks for a given context
Name | Type | Description |
---|---|---|
$context | string |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
clearContexts() : \Zend_Controller_Action_Helper_ContextSwitch
Remove all contexts
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
clearHeaders(string $context) : \Zend_Controller_Action_Helper_ContextSwitch
Clear all headers for a given context
Name | Type | Description |
---|---|---|
$context | string |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
direct() : \Zend_Controller_Action_Helper_ContextSwitch
Strategy pattern: return object
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
getActionContexts(string $action = null) : array
Get contexts for a given action or all actions in the controller
Name | Type | Description |
---|---|---|
$action | string |
Type | Description |
---|---|
array |
getAutoJsonSerialization() : boolean
Get JSON context auto-serialization flag
Type | Description |
---|---|
boolean |
getCallback(string $context, string $trigger) : string | array | null
Get a single callback for a given context and trigger
Name | Type | Description |
---|---|---|
$context | string | |
$trigger | string |
Type | Description |
---|---|
string | array | null |
getCallbacks(string $context) : array
Get all callbacks for a given context
Name | Type | Description |
---|---|---|
$context | string |
Type | Description |
---|---|
array |
getContext(string $context) : array | null
Retrieve context specification
Name | Type | Description |
---|---|---|
$context | string |
Type | Description |
---|---|
array | null |
getCurrentContext() : null | string
Return current context, if any
Type | Description |
---|---|
null | string |
getHeader(string $context, string $header) : string | null
Retrieve context header
Name | Type | Description |
---|---|---|
$context | string | |
$header | string |
Type | Description |
---|---|
string | null |
getHeaders(string $context) : array
Retrieve context headers
Name | Type | Description |
---|---|---|
$context | string |
Type | Description |
---|---|
array |
getSuffix(string $type) : string
Retrieve suffix for given context type
Name | Type | Description |
---|---|---|
$type | string | Context type |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Controller_Action_Exception |
hasActionContext(string $action, string | array $context) : boolean
Does a particular controller action have the given context(s)?
Name | Type | Description |
---|---|---|
$action | string | |
$context | string | array |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Controller_Action_Exception |
hasContext(string $context, boolean $throwException = false) : bool
Does the given context exist?
Name | Type | Description |
---|---|---|
$context | string | |
$throwException | boolean |
Type | Description |
---|---|
bool |
Exception | Description |
---|---|
\Zend_Controller_Action_Exception | if context does not exist and throwException is true |
init() : void
Initialize at start of action controller
initContext(mixed $format = null) : void
Initialize context detection and switching
Name | Type | Description |
---|---|---|
$format | mixed |
Exception | Description |
---|---|
\Zend_Controller_Action_Exception |
postDispatch() : void
Post dispatch processing
Exception | Description |
---|---|
\Zend_Controller_Action_Exception |
removeActionContext(string $action, string | array $context) : boolean
Remove one or more contexts for a given controller action
Name | Type | Description |
---|---|---|
$action | string | |
$context | string | array |
Type | Description |
---|---|
boolean |
removeCallback(string $context, string $trigger) : boolean
Clear a callback for a given context and trigger
Name | Type | Description |
---|---|---|
$context | string | |
$trigger | string |
Type | Description |
---|---|
boolean |
removeContext(string $context) : boolean
Remove a context
Name | Type | Description |
---|---|---|
$context | string |
Type | Description |
---|---|
boolean |
removeHeader(string $context, string $header) : boolean
Remove a single header from a context
Name | Type | Description |
---|---|---|
$context | string | |
$header | string |
Type | Description |
---|---|
boolean |
setActionContext(string $action, string | array $context) : \Zend_Controller_Action_Helper_ContextSwitch | void
Set a context as available for a given controller action
Name | Type | Description |
---|---|---|
$action | string | |
$context | string | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | void | Provides a fluent interface |
setActionContexts(array $contexts) : \Zend_Controller_Action_Helper_ContextSwitch
Overwrite and set multiple action contexts at once
Name | Type | Description |
---|---|---|
$contexts | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
setAutoDisableLayout(boolean $flag) : \Zend_Controller_Action_Helper_ContextSwitch
Set flag indicating if layout should be disabled
Name | Type | Description |
---|---|---|
$flag | boolean |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
setAutoJsonSerialization(boolean $flag) : \Zend_Controller_Action_Helper_ContextSwitch
Should JSON contexts auto-serialize?
Name | Type | Description |
---|---|---|
$flag | boolean |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
setCallback(string $context, string $trigger, string | array $callback) : \Zend_Controller_Action_Helper_ContextSwitch
Set a callback for a given context and trigger
Name | Type | Description |
---|---|---|
$context | string | |
$trigger | string | |
$callback | string | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
Exception | Description |
---|---|
\Zend_Controller_Action_Exception |
setCallbacks(string $context, array $callbacks) : \Zend_Controller_Action_Helper_ContextSwitch
Set callbacks for a given context
Name | Type | Description |
---|---|---|
$context | string | |
$callbacks | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
setConfig(\Zend_Config $config) : \Zend_Controller_Action_Helper_ContextSwitch
Set object state from config object
Name | Type | Description |
---|---|---|
$config | \Zend_Config |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
setContext(string $context, array $spec) : \Zend_Controller_Action_Helper_ContextSwitch
Overwrite existing context
Name | Type | Description |
---|---|---|
$context | string | Context type |
$spec | array | Context specification |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
setContextParam(string $name) : \Zend_Controller_Action_Helper_ContextSwitch
Set name of parameter to use when determining context format
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
setContexts(array $contexts) : \Zend_Controller_Action_Helper_ContextSwitch
Set multiple contexts, after first removing all
Name | Type | Description |
---|---|---|
$contexts | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
setDefaultContext(string $type) : \Zend_Controller_Action_Helper_ContextSwitch
Indicate default context to use when no context format provided
Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
Exception | Description |
---|---|
\Zend_Controller_Action_Exception |
setHeader( $context, string $header, string $content) : \Zend_Controller_Action_Helper_ContextSwitch
Customize response header to use when switching context
Name | Type | Description |
---|---|---|
$context | ||
$header | string | Header to set |
$content | string | Header content |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
setHeaders(string $context, array $headers) : \Zend_Controller_Action_Helper_ContextSwitch
Set multiple headers at once for a given context
Name | Type | Description |
---|---|---|
$context | string | |
$headers | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
setOptions(array $options) : \Zend_Controller_Action_Helper_ContextSwitch
Configure object from array of options
Name | Type | Description |
---|---|---|
$options | array |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
setSuffix(string $context, string $suffix, boolean $prependViewRendererSuffix = true) : \Zend_Controller_Action_Helper_ContextSwitch
Customize view script suffix to use when switching context.
Name | 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 |
Type | Description |
---|---|
\Zend_Controller_Action_Helper_ContextSwitch | Provides a fluent interface |
Exception | Description |
---|---|
\Zend_Controller_Action_Exception |