Simplify AJAX context switching based on requested format

uses
category Zend
package Zend_Controller
subpackage Zend_Controller_Action_Helper
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Controller_Action_Helper_Abstract

 Methods

Strategy pattern: call helper as helper broker method

direct(mixed $data, boolean $sendNow = true, boolean $keepLayouts = false, boolean $encodeData = true) : string | void

Allows encoding JSON. If $sendNow is true, immediately sends JSON response.

Parameters

$data

mixed

$sendNow

boolean

$keepLayouts

boolean

$encodeData

boolean

Encode $data as JSON?

Returns

stringvoid

Create JSON response

encodeJson(mixed $data, boolean|array $keepLayouts = false, boolean $encodeData = true) : string

Encodes and returns data to JSON. Content-Type header set to 'application/json', and disables layouts and viewRenderer (if being used).

Parameters

$data

mixed

$keepLayouts

booleanbooleanarray

$encodeData

boolean

Provided data is already JSON NOTE: if boolean, establish $keepLayouts to true|false if array, admit params for Zend_Json::encode as enableJsonExprFinder=>true|false if $keepLayouts and parmas for Zend_Json::encode are required then, the array can contains a 'keepLayout'=>true|false and/or 'encodeData'=>true|false that will not be passed to Zend_Json::encode method but will be passed to Zend_View_Helper_Json

Exceptions

\Zend_Controller_Action_Helper_Json

Returns

string

Retrieve current action controller

getActionController() : \Zend_Controller_Action
Inherited

Returns

\Zend_Controller_Action

Retrieve front controller instance

getFrontController() : \Zend_Controller_Front
Inherited

Returns

\Zend_Controller_Front

getName()

getName() : string
Inherited

Returns

string

getRequest() -

getRequest() : \Zend_Controller_Request_Abstract
Inherited

Returns

\Zend_Controller_Request_Abstract$request

getResponse() -

getResponse() : \Zend_Controller_Response_Abstract
Inherited

Returns

\Zend_Controller_Response_Abstract$response

Hook into action controller initialization

init() : void
Inherited

Hook into action controller postDispatch() workflow

postDispatch() : void
Inherited

Hook into action controller preDispatch() workflow

preDispatch() : void
Inherited

Encode JSON response and immediately send

sendJson(mixed $data, boolean|array $keepLayouts = false, $encodeData = true) : string | void

Parameters

$data

mixed

$keepLayouts

booleanarray

$encodeData

Encode $data as JSON? NOTE: if boolean, establish $keepLayouts to true|false if array, admit params for Zend_Json::encode as enableJsonExprFinder=>true|false if $keepLayouts and parmas for Zend_Json::encode are required then, the array can contains a 'keepLayout'=>true|false and/or 'encodeData'=>true|false that will not be passed to Zend_Json::encode method but will be passed to Zend_View_Helper_Json

Returns

stringvoid

setActionController()

setActionController(\Zend_Controller_Action $actionController = null) : \Zend_Controller_ActionHelper_Abstract
Inherited

Parameters

$actionController

\Zend_Controller_Action

Returns

\Zend_Controller_ActionHelper_AbstractProvides a fluent interface

 Properties

 

Suppress exit when sendJson() called

$suppressExit : boolean

Default

false
 

$_actionController

$_actionController : \Zend_Controller_Action

Default

null
 

$_frontController

$_frontController : mixed

Default

null