Controller/Action/Helper/AjaxContext.php

Show: PublicProtectedPrivateinherited
Table of Contents
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-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Controller  
Subpackage
Zend_Controller_Action_Helper  
Version
$Id: AjaxContext.php 24593 2012-01-05 20:35:02Z matthew $  

\Zend_Controller_Action_Helper_AjaxContext

Package: Zend\Controller\Zend\Controller\Action\Helper
Simplify AJAX context switching based on requested format
Parent(s)
\Zend_Controller_Action_Helper_ContextSwitch < \Zend_Controller_Action_Helper_Abstract
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Uses
\global\Zend_Controller_Action_Helper_Abstract  

Constants

>VConstant  TRIGGER_INIT = 'TRIGGER_INIT'
inherited
Trigger type constants
Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::TRIGGER_INIT

Properties

>VPropertyprotectedboolean $_autoJsonSerialization = true
inherited
JSON auto-serialization flag
Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::$$_autoJsonSerialization
Default valuetrueDetails
Type
boolean
Inherited_from
\Zend_Controller_Action_Helper_ContextSwitch::$$_autoJsonSerialization  
>VPropertyprotectedstring $_contextKey = 'ajaxable'
Controller property to utilize for context switching
Default value'ajaxable'Details
Type
string
>VPropertyprotectedstring $_contextParam = 'format'
inherited
Request parameter containing requested context
Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::$$_contextParam
Default value'format'Details
Type
string
Inherited_from
\Zend_Controller_Action_Helper_ContextSwitch::$$_contextParam  
>VPropertyprotectedarray $_contexts = array()
inherited
Supported contexts
Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::$$_contexts
Default valuearray()Details
Type
array
Inherited_from
\Zend_Controller_Action_Helper_ContextSwitch::$$_contexts  
>VPropertyprotectedstring $_currentContext
>VPropertyprotectedstring $_defaultContext = 'xml'
inherited
Default context (xml)
Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::$$_defaultContext
Default value'xml'Details
Type
string
Inherited_from
\Zend_Controller_Action_Helper_ContextSwitch::$$_defaultContext  
>VPropertyprotectedboolean $_disableLayout = true
inherited
Whether or not to disable layouts when switching contexts
Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::$$_disableLayout
Default valuetrueDetails
Type
boolean
Inherited_from
\Zend_Controller_Action_Helper_ContextSwitch::$$_disableLayout  
>VPropertyprotectedarray $_specialConfig = array('setSuffix', 'setHeaders', 'setCallbacks')
inherited
Methods that require special configuration
Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::$$_specialConfig
Default valuearray('setSuffix', 'setHeaders', 'setCallbacks')Details
Type
array
Inherited_from
\Zend_Controller_Action_Helper_ContextSwitch::$$_specialConfig  
>VPropertyprotectedarray $_unconfigurable = array('setOptions', 'setConfig', 'setHeader', 'setCallback', 'setContext', 'setActionContext', 'setActionContexts')
inherited
Methods that are not configurable via setOptions and setConfig
Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::$$_unconfigurable
Default valuearray('setOptions', 'setConfig', 'setHeader', 'setCallback', 'setContext', 'setActionContext', 'setActionContexts')Details
Type
array
Inherited_from
\Zend_Controller_Action_Helper_ContextSwitch::$$_unconfigurable  
>VPropertyprotected\Zend_Controller_Action_Helper_ViewRenderer $_viewRenderer
>VPropertyprotectedstring $_viewSuffixOrig
inherited
Original view suffix prior to detecting context switch
Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::$$_viewSuffixOrig

Methods

methodpublic__construct() : void

Constructor

Add HTML context

methodprotected_getViewRenderer() : \Zend_Controller_Action_Helper_ViewRenderer
inherited

Retrieve ViewRenderer

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::_getViewRenderer()
Returns
TypeDescription
\Zend_Controller_Action_Helper_ViewRendererProvides a fluent interface
methodprotected_setCallbacks(array $options) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Set callbacks from array of context => callbacks pairs

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::_setCallbacks()
Parameters
NameTypeDescription
$optionsarray
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodprotected_setHeaders(array $options) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Set headers from context => headers pairs

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::_setHeaders()
Parameters
NameTypeDescription
$optionsarray
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodprotected_setSuffix(array $spec) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Set suffix from array

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::_setSuffix()
Parameters
NameTypeDescription
$specarray
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodprotected_validateTrigger(string $trigger) : string
inherited

Validate trigger and return in normalized form

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::_validateTrigger()
Parameters
NameTypeDescription
$triggerstring
Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Controller_Action_Exception
methodpublicaddActionContext(string $action, string | array $context) : \Zend_Controller_Action_Helper_ContextSwitch | void
inherited

Add one or more contexts to an action

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::addActionContext()
Parameters
NameTypeDescription
$actionstring
$contextstring | array
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitch | voidProvides a fluent interface
methodpublicaddActionContexts(array $contexts) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Add multiple action/context pairs at once

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::addActionContexts()
Parameters
NameTypeDescription
$contextsarray
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicaddContext(string $context, array $spec) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Add new context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::addContext()
Parameters
NameTypeDescription
$contextstring

Context type

$specarray

Context specification

Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
Throws
ExceptionDescription
\Zend_Controller_Action_Exception
methodpublicaddContexts(array $contexts) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Add multiple contexts

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::addContexts()
Parameters
NameTypeDescription
$contextsarray
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicaddHeader(string $context, string $header, string $content) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Add header to context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::addHeader()
Parameters
NameTypeDescription
$contextstring
$headerstring
$contentstring
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
Throws
ExceptionDescription
\Zend_Controller_Action_Exception
methodpublicaddHeaders(string $context, array $headers) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Add multiple headers at once for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::addHeaders()
Parameters
NameTypeDescription
$contextstring
$headersarray
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicclearActionContexts(string $action = null) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Clear all contexts for a given controller action or all actions

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::clearActionContexts()
Parameters
NameTypeDescription
$actionstring
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicclearCallbacks(string $context) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Clear all callbacks for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::clearCallbacks()
Parameters
NameTypeDescription
$contextstring
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicclearContexts() : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Remove all contexts

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::clearContexts()
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicclearHeaders(string $context) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Clear all headers for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::clearHeaders()
Parameters
NameTypeDescription
$contextstring
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicdirect() : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Strategy pattern: return object

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::direct()
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicgetActionContexts(string $action = null) : array
inherited

Get contexts for a given action or all actions in the controller

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getActionContexts()
Parameters
NameTypeDescription
$actionstring
Returns
TypeDescription
array
methodpublicgetAutoDisableLayout() : boolean
inherited

Retrieve auto layout disable flag

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getAutoDisableLayout()
Returns
TypeDescription
boolean
methodpublicgetAutoJsonSerialization() : boolean
inherited

Get JSON context auto-serialization flag

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getAutoJsonSerialization()
Returns
TypeDescription
boolean
methodpublicgetCallback(string $context, string $trigger) : string | array | null
inherited

Get a single callback for a given context and trigger

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getCallback()
Parameters
NameTypeDescription
$contextstring
$triggerstring
Returns
TypeDescription
string | array | null
methodpublicgetCallbacks(string $context) : array
inherited

Get all callbacks for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getCallbacks()
Parameters
NameTypeDescription
$contextstring
Returns
TypeDescription
array
methodpublicgetContext(string $context) : array | null
inherited

Retrieve context specification

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getContext()
Parameters
NameTypeDescription
$contextstring
Returns
TypeDescription
array | null
methodpublicgetContextParam() : string
inherited

Return context format request parameter name

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getContextParam()
Returns
TypeDescription
string
methodpublicgetContexts() : array
inherited

Retrieve context definitions

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getContexts()
Returns
TypeDescription
array
methodpublicgetCurrentContext() : null | string
inherited

Return current context, if any

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getCurrentContext()
Returns
TypeDescription
null | string
methodpublicgetDefaultContext() : string
inherited

Return default context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getDefaultContext()
Returns
TypeDescription
string
methodpublicgetHeader(string $context, string $header) : string | null
inherited

Retrieve context header

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getHeader()

Returns the value of a given header for a given context type

Parameters
NameTypeDescription
$contextstring
$headerstring
Returns
TypeDescription
string | null
methodpublicgetHeaders(string $context) : array
inherited

Retrieve context headers

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getHeaders()

Returns all headers for a context as key/value pairs

Parameters
NameTypeDescription
$contextstring
Returns
TypeDescription
array
methodpublicgetName() : string
Returns
TypeDescription
string
methodpublicgetSuffix(string $type) : string
inherited

Retrieve suffix for given context type

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getSuffix()
Parameters
NameTypeDescription
$typestring

Context type

Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Controller_Action_Exception
methodpublichasActionContext(string $action, string | array $context) : boolean
inherited

Does a particular controller action have the given context(s)?

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::hasActionContext()
Parameters
NameTypeDescription
$actionstring
$contextstring | array
Returns
TypeDescription
boolean
Throws
ExceptionDescription
\Zend_Controller_Action_Exception
methodpublichasContext(string $context, boolean $throwException = false) : bool
inherited

Does the given context exist?

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::hasContext()
Parameters
NameTypeDescription
$contextstring
$throwExceptionboolean
Returns
TypeDescription
bool
Throws
ExceptionDescription
\Zend_Controller_Action_Exceptionif context does not exist and throwException is true
methodpublicinit() : void
inherited

Initialize at start of action controller

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::init()

Reset the view script suffix to the original state, or store the original state.

methodpublicinitContext(string $format = null) : void

Initialize AJAX context switching

Checks for XHR requests; if detected, attempts to perform context switch.

Parameters
NameTypeDescription
$formatstring
Throws
ExceptionDescription
\Zend_Controller_Action_Exception
methodpublicinitJsonContext() : void
inherited

JSON context extra initialization

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::initJsonContext()

Turns off viewRenderer auto-rendering

methodpublicpostDispatch() : void
inherited

Post dispatch processing

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::postDispatch()

Execute postDispatch callback for current context, if available

Throws
ExceptionDescription
\Zend_Controller_Action_Exception
methodpublicpostJsonContext() : void
inherited

JSON post processing

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::postJsonContext()

JSON serialize view variables to response body

methodpublicpreDispatch() : void
methodpublicremoveActionContext(string $action, string | array $context) : boolean
inherited

Remove one or more contexts for a given controller action

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::removeActionContext()
Parameters
NameTypeDescription
$actionstring
$contextstring | array
Returns
TypeDescription
boolean
methodpublicremoveCallback(string $context, string $trigger) : boolean
inherited

Clear a callback for a given context and trigger

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::removeCallback()
Parameters
NameTypeDescription
$contextstring
$triggerstring
Returns
TypeDescription
boolean
methodpublicremoveContext(string $context) : boolean
inherited

Remove a context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::removeContext()
Parameters
NameTypeDescription
$contextstring
Returns
TypeDescription
boolean
methodpublicremoveHeader(string $context, string $header) : boolean
inherited

Remove a single header from a context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::removeHeader()
Parameters
NameTypeDescription
$contextstring
$headerstring
Returns
TypeDescription
boolean
methodpublicsetActionContext(string $action, string | array $context) : \Zend_Controller_Action_Helper_ContextSwitch | void
inherited

Set a context as available for a given controller action

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setActionContext()
Parameters
NameTypeDescription
$actionstring
$contextstring | array
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitch | voidProvides a fluent interface
methodpublicsetActionContexts(array $contexts) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Overwrite and set multiple action contexts at once

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setActionContexts()
Parameters
NameTypeDescription
$contextsarray
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicsetActionController(\Zend_Controller_Action $actionController = null) : \Zend_Controller_ActionHelper_Abstract
Parameters
NameTypeDescription
$actionController\Zend_Controller_Action
Returns
TypeDescription
\Zend_Controller_ActionHelper_AbstractProvides a fluent interface
methodpublicsetAutoDisableLayout(boolean $flag) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Set flag indicating if layout should be disabled

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setAutoDisableLayout()
Parameters
NameTypeDescription
$flagboolean
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicsetAutoJsonSerialization(boolean $flag) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Should JSON contexts auto-serialize?

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setAutoJsonSerialization()
Parameters
NameTypeDescription
$flagboolean
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicsetCallback(string $context, string $trigger, string | array $callback) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Set a callback for a given context and trigger

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setCallback()
Parameters
NameTypeDescription
$contextstring
$triggerstring
$callbackstring | array
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
Throws
ExceptionDescription
\Zend_Controller_Action_Exception
methodpublicsetCallbacks(string $context, array $callbacks) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Set callbacks for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setCallbacks()

Callbacks should be in trigger/callback pairs.

Parameters
NameTypeDescription
$contextstring
$callbacksarray
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicsetConfig(\Zend_Config $config) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Set object state from config object

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setConfig()
Parameters
NameTypeDescription
$config\Zend_Config
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicsetContext(string $context, array $spec) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Overwrite existing context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setContext()
Parameters
NameTypeDescription
$contextstring

Context type

$specarray

Context specification

Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicsetContextParam(string $name) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Set name of parameter to use when determining context format

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setContextParam()
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicsetContexts(array $contexts) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Set multiple contexts, after first removing all

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setContexts()
Parameters
NameTypeDescription
$contextsarray
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicsetDefaultContext(string $type) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Indicate default context to use when no context format provided

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setDefaultContext()
Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
Throws
ExceptionDescription
\Zend_Controller_Action_Exception
methodpublicsetHeader( $context, string $header, string $content) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Customize response header to use when switching context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setHeader()

Passing an empty header value to the setters disables the response header.

Parameters
NameTypeDescription
$context
$headerstring

Header to set

$contentstring

Header content

Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicsetHeaders(string $context, array $headers) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Set multiple headers at once for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setHeaders()
Parameters
NameTypeDescription
$contextstring
$headersarray
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicsetOptions(array $options) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Configure object from array of options

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setOptions()
Parameters
NameTypeDescription
$optionsarray
Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
methodpublicsetSuffix(string $context, string $suffix, boolean $prependViewRendererSuffix = true) : \Zend_Controller_Action_Helper_ContextSwitch
inherited

Customize view script suffix to use when switching context.

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setSuffix()

Passing an empty suffix value to the setters disables the view script suffix change.

Parameters
NameTypeDescription
$contextstring

Context type for which to set suffix

$suffixstring

Suffix to use

$prependViewRendererSuffixboolean

Whether or not to prepend the new suffix to the viewrenderer suffix

Returns
TypeDescription
\Zend_Controller_Action_Helper_ContextSwitchProvides a fluent interface
Throws
ExceptionDescription
\Zend_Controller_Action_Exception
Documentation was generated by phpDocumentor 2.0.0a12.