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 license@zend.com so we can send you a copy immediately.
- 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_Json
Package: Zend_Controller\Zend_Controller_Action_HelperSimplify AJAX context switching based on requested format
- Parent(s)
- \Zend_Controller_Action_Helper_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Uses
-
Properties
boolean $suppressExit = false
Suppress exit when sendJson() called
Default valuefalse
Details- Type
- boolean
Methods
direct(mixed $data, boolean $sendNow = true, boolean $keepLayouts = false, boolean $encodeData = true) : string | void
Strategy pattern: call helper as helper broker method
Allows encoding JSON. If $sendNow is true, immediately sends JSON
response.
ParametersName | Type | Description |
---|
$data | mixed | |
---|
$sendNow | boolean | |
---|
$keepLayouts | boolean | |
---|
$encodeData | boolean | Encode $data as JSON? |
---|
ReturnsType | Description |
---|
string | void | |
encodeJson(mixed $data, boolean | 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).
ParametersName | 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
|
---|
ReturnsThrowssendJson(mixed $data, boolean | array $keepLayouts = false, $encodeData = true) : string | void
Encode JSON response and immediately send
ParametersName | Type | Description |
---|
$data | mixed | |
---|
$keepLayouts | boolean | array | |
---|
$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
|
---|
ReturnsType | Description |
---|
string | void | |