Controller/Action/Helper/Json.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 [email protected] 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: Json.php 24829 2012-05-30 12:31:39Z adamlundrigan $
\Zend_Controller_Action_Helper_Json
Simplify AJAX context switching based on requested format
- Parent(s)
- \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
Properties

\Zend_Controller_Action $_actionController = null$_actionController
Inherited from: \Zend_Controller_Action_Helper_Abstract::$$_actionControllernullDetails- Type
- \Zend_Controller_Action
- Inherited_from
- \Zend_Controller_Action_Helper_Abstract::$$_actionController

mixed $_frontController = nullnullDetails- Type
- mixed
- Inherited_from
- \Zend_Controller_Action_Helper_Abstract::$$_frontController
Methods

direct(mixed $data, boolean $sendNow = true, boolean $keepLayouts = false, boolean $encodeData = true) : string | voidStrategy pattern: call helper as helper broker method
Allows encoding JSON. If $sendNow is true, immediately sends JSON response.
| Name | Type | Description |
|---|---|---|
| $data | mixed | |
| $sendNow | boolean | |
| $keepLayouts | boolean | |
| $encodeData | boolean | Encode $data as JSON? |
| Type | Description |
|---|---|
| string | void |

encodeJson(mixed $data, boolean | boolean | array $keepLayouts = false, boolean $encodeData = true) : stringCreate JSON response
Encodes and returns data to JSON. Content-Type header set to 'application/json', and disables layouts and viewRenderer (if being used).
| Name | Type | Description |
|---|---|---|
| $data | mixed | |
| $keepLayouts | boolean | boolean | array | |
| $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 |
| Type | Description |
|---|---|
| string |
| Exception | Description |
|---|---|
| \Zend_Controller_Action_Helper_Json |

getActionController() : \Zend_Controller_ActionRetrieve current action controller
Inherited from: \Zend_Controller_Action_Helper_Abstract::getActionController()| Type | Description |
|---|---|
| \Zend_Controller_Action |

getFrontController() : \Zend_Controller_FrontRetrieve front controller instance
Inherited from: \Zend_Controller_Action_Helper_Abstract::getFrontController()| Type | Description |
|---|---|
| \Zend_Controller_Front |

getRequest() : \Zend_Controller_Request_Abstract
| Type | Description |
|---|---|
| \Zend_Controller_Request_Abstract | $request |

getResponse() : \Zend_Controller_Response_Abstract
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract | $response |

init() : voidHook into action controller initialization
Inherited from: \Zend_Controller_Action_Helper_Abstract::init()
postDispatch() : voidHook into action controller postDispatch() workflow
Inherited from: \Zend_Controller_Action_Helper_Abstract::postDispatch()
preDispatch() : voidHook into action controller preDispatch() workflow
Inherited from: \Zend_Controller_Action_Helper_Abstract::preDispatch()
sendJson(mixed $data, boolean | array $keepLayouts = false, \$encodeData $encodeData = true) : string | voidEncode JSON response and immediately send
| Name | Type | Description |
|---|---|---|
| $data | mixed | |
| $keepLayouts | boolean | array | |
| $encodeData | \$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 |
| Type | Description |
|---|---|
| string | void |

setActionController(\Zend_Controller_Action $actionController = null) : \Zend_Controller_ActionHelper_AbstractsetActionController()
Inherited from: \Zend_Controller_Action_Helper_Abstract::setActionController()| Name | Type | Description |
|---|---|---|
| $actionController | \Zend_Controller_Action |
| Type | Description |
|---|---|
| \Zend_Controller_ActionHelper_Abstract | Provides a fluent interface |