Controller/Action/Helper/Json.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: Json.php 24829 2012-05-30 12:31:39Z adamlundrigan $  

\Zend_Controller_Action_Helper_Json

Package: Zend\Controller\Zend\Controller\Action\Helper
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

>VPropertyprotected\Zend_Controller_Action $_actionController = null
inherited
$_actionController
Inherited from: \Zend_Controller_Action_Helper_Abstract::$$_actionController
>VPropertyprotectedmixed $_frontController = null
Default valuenullDetails
Type
mixed
Inherited_from
\Zend_Controller_Action_Helper_Abstract::$$_frontController  
>VPropertypublicboolean $suppressExit = false
Suppress exit when sendJson() called
Default valuefalseDetails
Type
boolean

Methods

methodpublicdirect(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.

Parameters
NameTypeDescription
$datamixed
$sendNowboolean
$keepLayoutsboolean
$encodeDataboolean

Encode $data as JSON?

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

Create JSON response

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

Parameters
NameTypeDescription
$datamixed
$keepLayoutsboolean | boolean | array
$encodeDataboolean

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

Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Controller_Action_Helper_Json
methodpublicgetActionController() : \Zend_Controller_Action
inherited

Retrieve current action controller

Inherited from: \Zend_Controller_Action_Helper_Abstract::getActionController()
Returns
TypeDescription
\Zend_Controller_Action
methodpublicgetFrontController() : \Zend_Controller_Front
inherited

Retrieve front controller instance

Inherited from: \Zend_Controller_Action_Helper_Abstract::getFrontController()
Returns
TypeDescription
\Zend_Controller_Front
methodpublicgetName() : string
inherited

getName()

Inherited from: \Zend_Controller_Action_Helper_Abstract::getName()
Returns
TypeDescription
string
methodpublicgetRequest() : \Zend_Controller_Request_Abstract
inherited

getRequest() -

Inherited from: \Zend_Controller_Action_Helper_Abstract::getRequest()
Returns
TypeDescription
\Zend_Controller_Request_Abstract$request
methodpublicgetResponse() : \Zend_Controller_Response_Abstract
inherited

getResponse() -

Inherited from: \Zend_Controller_Action_Helper_Abstract::getResponse()
Returns
TypeDescription
\Zend_Controller_Response_Abstract$response
methodpublicinit() : void
inherited

Hook into action controller initialization

Inherited from: \Zend_Controller_Action_Helper_Abstract::init()
methodpublicpostDispatch() : void
inherited

Hook into action controller postDispatch() workflow

Inherited from: \Zend_Controller_Action_Helper_Abstract::postDispatch()
methodpublicpreDispatch() : void
inherited

Hook into action controller preDispatch() workflow

Inherited from: \Zend_Controller_Action_Helper_Abstract::preDispatch()
methodpublicsendJson(mixed $data, boolean | array $keepLayouts = false,  $encodeData = true) : string | void

Encode JSON response and immediately send

Parameters
NameTypeDescription
$datamixed
$keepLayoutsboolean | 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

Returns
TypeDescription
string | void
methodpublicsetActionController(\Zend_Controller_Action $actionController = null) : \Zend_Controller_ActionHelper_Abstract
inherited

setActionController()

Inherited from: \Zend_Controller_Action_Helper_Abstract::setActionController()
Parameters
NameTypeDescription
$actionController\Zend_Controller_Action
Returns
TypeDescription
\Zend_Controller_ActionHelper_AbstractProvides a fluent interface
Documentation was generated by phpDocumentor 2.0.0a12.