Source for file JsonResponse.php
Documentation is available at JsonResponse.php
6: * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
8: * This source file is subject to the "Nette license" that is bundled
9: * with this package in the file license.txt.
11: * For more information please see http://nettephp.com
13: * @copyright Copyright (c) 2004, 2009 David Grudl
14: * @license http://nettephp.com/license Nette license
15: * @link http://nettephp.com
17: * @package Nette\Application
22: require_once dirname(__FILE__) .
'/../../Object.php';
24: require_once dirname(__FILE__) .
'/../../Application/IPresenterResponse.php';
29: * JSON response used for AJAX requests.
31: * @author David Grudl
32: * @copyright Copyright (c) 2004, 2009 David Grudl
33: * @package Nette\Application
37: /** @var array|stdClass*/
41: private $contentType;
46: * @param array|stdClass payload
47: * @param string MIME content type
51: if (!is_array($payload) &&
!($payload instanceof
stdClass)) {
52: throw new InvalidArgumentException("Payload must be array or anonymous class, " .
gettype($payload) .
" given.");
54: $this->payload =
$payload;
55: $this->contentType =
$contentType ?
$contentType :
'application/json';
61: * @return array|stdClass
65: return $this->payload;
71: * Sends response to output.