API Documentation

Controller/Action/Helper/AjaxContext.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: AjaxContext.php 24131 2011-06-09 08:37:20Z freak $  

\Zend_Controller_Action_Helper_AjaxContext

Simplify AJAX context switching based on requested format

Extends from
\Zend_Controller_Action_Helper_ContextSwitch
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  
uses
\Zend_Controller_Action_Helper_Abstract  

Properties

Propertyprotectedstring  $_contextKey= 'ajaxable'

Controller property to utilize for context switching

Default valueajaxableDetails
Type
string

Methods

methodpublic__construct( ) : void

Constructor

Add HTML context

methodprotected_getViewRenderer( ) : \Zend_Controller_Action_Helper_ViewRenderer
Returns
Type Description
\Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
methodprotected_setCallbacks( array $options ) : \Zend_Controller_Action_Helper_ContextSwitch

Set callbacks from array of context => callbacks pairs

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::_setCallbacks()
Parameters
Name Type Description
$options array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodprotected_setHeaders( array $options ) : \Zend_Controller_Action_Helper_ContextSwitch

Set headers from context => headers pairs

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::_setHeaders()
Parameters
Name Type Description
$options array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodprotected_setSuffix( array $spec ) : \Zend_Controller_Action_Helper_ContextSwitch

Set suffix from array

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::_setSuffix()
Parameters
Name Type Description
$spec array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodprotected_validateTrigger( string $trigger ) : string

Validate trigger and return in normalized form

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::_validateTrigger()
Parameters
Name Type Description
$trigger string
Returns
Type Description
string
Throws
Exception Description
\Zend_Controller_Action_Exception
methodpublicaddActionContext( string $action, string|array $context ) : \Zend_Controller_Action_Helper_ContextSwitch|void

Add one or more contexts to an action

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::addActionContext()
Parameters
Name Type Description
$action string
$context string|array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitchvoid Provides a fluent interface
methodpublicaddActionContexts( array $contexts ) : \Zend_Controller_Action_Helper_ContextSwitch

Add multiple action/context pairs at once

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::addActionContexts()
Parameters
Name Type Description
$contexts array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicaddContext( string $context, array $spec ) : \Zend_Controller_Action_Helper_ContextSwitch
Parameters
Name Type Description
$context string Context type
$spec array Context specification
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
Throws
Exception Description
\Zend_Controller_Action_Exception
methodpublicaddContexts( array $contexts ) : \Zend_Controller_Action_Helper_ContextSwitch

Add multiple contexts

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::addContexts()
Parameters
Name Type Description
$contexts array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicaddHeader( string $context, string $header, string $content ) : \Zend_Controller_Action_Helper_ContextSwitch

Add header to context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::addHeader()
Parameters
Name Type Description
$context string
$header string
$content string
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
Throws
Exception Description
\Zend_Controller_Action_Exception
methodpublicaddHeaders( string $context, array $headers ) : \Zend_Controller_Action_Helper_ContextSwitch

Add multiple headers at once for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::addHeaders()
Parameters
Name Type Description
$context string
$headers array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicclearActionContexts( string $action = null ) : \Zend_Controller_Action_Helper_ContextSwitch

Clear all contexts for a given controller action or all actions

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::clearActionContexts()
Parameters
Name Type Description
$action string
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicclearCallbacks( string $context ) : \Zend_Controller_Action_Helper_ContextSwitch

Clear all callbacks for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::clearCallbacks()
Parameters
Name Type Description
$context string
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicclearContexts( ) : \Zend_Controller_Action_Helper_ContextSwitch
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicclearHeaders( string $context ) : \Zend_Controller_Action_Helper_ContextSwitch

Clear all headers for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::clearHeaders()
Parameters
Name Type Description
$context string
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicdirect( ) : \Zend_Controller_Action_Helper_ContextSwitch

Strategy pattern: return object

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::direct()
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicgetActionContexts( string $action = null ) : array

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

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getActionContexts()
Parameters
Name Type Description
$action string
Returns
Type Description
array
methodpublicgetActionController( ) : \Zend_Controller_Action

Retrieve current action controller

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

Retrieve auto layout disable flag

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getAutoDisableLayout()
Returns
Type Description
boolean
methodpublicgetAutoJsonSerialization( ) : boolean

Get JSON context auto-serialization flag

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

Get a single callback for a given context and trigger

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getCallback()
Parameters
Name Type Description
$context string
$trigger string
Returns
Type Description
stringarraynull
methodpublicgetCallbacks( string $context ) : array

Get all callbacks for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getCallbacks()
Parameters
Name Type Description
$context string
Returns
Type Description
array
methodpublicgetContext( string $context ) : array|null

Retrieve context specification

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getContext()
Parameters
Name Type Description
$context string
Returns
Type Description
arraynull
methodpublicgetContextParam( ) : string

Return context format request parameter name

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getContextParam()
Returns
Type Description
string
methodpublicgetContexts( ) : array

Retrieve context definitions

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getContexts()
Returns
Type Description
array
methodpublicgetCurrentContext( ) : null|string

Return current context, if any

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getCurrentContext()
Returns
Type Description
nullstring
methodpublicgetDefaultContext( ) : string
Returns
Type Description
string
methodpublicgetFrontController( ) : \Zend_Controller_Front

Retrieve front controller instance

Inherited from: \Zend_Controller_Action_Helper_Abstract::getFrontController()
Returns
Type Description
\Zend_Controller_Front
methodpublicgetHeader( string $context, string $header ) : string|null

Retrieve context header

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getHeader()

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

Parameters
Name Type Description
$context string
$header string
Returns
Type Description
stringnull
methodpublicgetHeaders( string $context ) : array

Retrieve context headers

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getHeaders()

Returns all headers for a context as key/value pairs

Parameters
Name Type Description
$context string
Returns
Type Description
array
methodpublicgetName( ) : string
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
methodpublicgetSuffix( string $type ) : string

Retrieve suffix for given context type

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::getSuffix()
Parameters
Name Type Description
$type string Context type
Returns
Type Description
string
Throws
Exception Description
\Zend_Controller_Action_Exception
methodpublichasActionContext( string $action, string|array $context ) : boolean

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

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::hasActionContext()
Parameters
Name Type Description
$action string
$context string|array
Returns
Type Description
boolean
Throws
Exception Description
\Zend_Controller_Action_Exception
methodpublichasContext( string $context, boolean $throwException = false ) : bool

Does the given context exist?

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::hasContext()
Parameters
Name Type Description
$context string
$throwException boolean
Returns
Type Description
bool
Throws
Exception Description
\Zend_Controller_Action_Exception if context does not exist and throwException is true
methodpublicinit( ) : void

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
Name Type Description
$format string
Throws
Exception Description
\Zend_Controller_Action_Exception
methodpublicinitJsonContext( ) : void

JSON context extra initialization

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::initJsonContext()

Turns off viewRenderer auto-rendering

methodpublicpostDispatch( ) : void

Post dispatch processing

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::postDispatch()

Execute postDispatch callback for current context, if available

Throws
Exception Description
\Zend_Controller_Action_Exception
methodpublicpostJsonContext( ) : void

JSON serialize view variables to response body

methodpublicpreDispatch( ) : void

Hook into action controller preDispatch() workflow

Inherited from: \Zend_Controller_Action_Helper_Abstract::preDispatch()
methodpublicremoveActionContext( string $action, string|array $context ) : boolean

Remove one or more contexts for a given controller action

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::removeActionContext()
Parameters
Name Type Description
$action string
$context string|array
Returns
Type Description
boolean
methodpublicremoveCallback( string $context, string $trigger ) : boolean

Clear a callback for a given context and trigger

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::removeCallback()
Parameters
Name Type Description
$context string
$trigger string
Returns
Type Description
boolean
methodpublicremoveContext( string $context ) : boolean
Parameters
Name Type Description
$context string
Returns
Type Description
boolean
methodpublicremoveHeader( string $context, string $header ) : boolean

Remove a single header from a context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::removeHeader()
Parameters
Name Type Description
$context string
$header string
Returns
Type Description
boolean
methodpublicsetActionContext( string $action, string|array $context ) : \Zend_Controller_Action_Helper_ContextSwitch|void

Set a context as available for a given controller action

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setActionContext()
Parameters
Name Type Description
$action string
$context string|array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitchvoid Provides a fluent interface
methodpublicsetActionContexts( array $contexts ) : \Zend_Controller_Action_Helper_ContextSwitch

Overwrite and set multiple action contexts at once

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setActionContexts()
Parameters
Name Type Description
$contexts array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
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
methodpublicsetAutoDisableLayout( boolean $flag ) : \Zend_Controller_Action_Helper_ContextSwitch

Set flag indicating if layout should be disabled

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setAutoDisableLayout()
Parameters
Name Type Description
$flag boolean
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicsetAutoJsonSerialization( boolean $flag ) : \Zend_Controller_Action_Helper_ContextSwitch

Should JSON contexts auto-serialize?

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setAutoJsonSerialization()
Parameters
Name Type Description
$flag boolean
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicsetCallback( string $context, string $trigger, string|array $callback ) : \Zend_Controller_Action_Helper_ContextSwitch

Set a callback for a given context and trigger

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setCallback()
Parameters
Name Type Description
$context string
$trigger string
$callback string|array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
Throws
Exception Description
\Zend_Controller_Action_Exception
methodpublicsetCallbacks( string $context, array $callbacks ) : \Zend_Controller_Action_Helper_ContextSwitch

Set callbacks for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setCallbacks()

Callbacks should be in trigger/callback pairs.

Parameters
Name Type Description
$context string
$callbacks array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicsetConfig( \Zend_Config $config ) : \Zend_Controller_Action_Helper_ContextSwitch

Set object state from config object

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setConfig()
Parameters
Name Type Description
$config \Zend_Config
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicsetContext( string $context, array $spec ) : \Zend_Controller_Action_Helper_ContextSwitch

Overwrite existing context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setContext()
Parameters
Name Type Description
$context string Context type
$spec array Context specification
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicsetContextParam( string $name ) : \Zend_Controller_Action_Helper_ContextSwitch

Set name of parameter to use when determining context format

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setContextParam()
Parameters
Name Type Description
$name string
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicsetContexts( array $contexts ) : \Zend_Controller_Action_Helper_ContextSwitch

Set multiple contexts, after first removing all

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setContexts()
Parameters
Name Type Description
$contexts array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicsetDefaultContext( string $type ) : \Zend_Controller_Action_Helper_ContextSwitch

Indicate default context to use when no context format provided

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setDefaultContext()
Parameters
Name Type Description
$type string
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
Throws
Exception Description
\Zend_Controller_Action_Exception
methodpublicsetHeader(  $context, string $header, string $content ) : \Zend_Controller_Action_Helper_ContextSwitch

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
Name Type Description
$context
$header string Header to set
$content string Header content
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicsetHeaders( string $context, array $headers ) : \Zend_Controller_Action_Helper_ContextSwitch

Set multiple headers at once for a given context

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setHeaders()
Parameters
Name Type Description
$context string
$headers array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicsetOptions( array $options ) : \Zend_Controller_Action_Helper_ContextSwitch

Configure object from array of options

Inherited from: \Zend_Controller_Action_Helper_ContextSwitch::setOptions()
Parameters
Name Type Description
$options array
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
methodpublicsetSuffix( string $context, string $suffix, boolean $prependViewRendererSuffix = true ) : \Zend_Controller_Action_Helper_ContextSwitch

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
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
Returns
Type Description
\Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
Throws
Exception Description
\Zend_Controller_Action_Exception
Documentation was generated by DocBlox 0.13.3.