HummingBirdAnimeClient/src/Aviat/Ion/View/JsonView.php

47 lines
730 B
PHP
Raw Normal View History

2015-09-17 23:11:18 -04:00
<?php
2015-11-16 11:40:01 -05:00
/**
* Ion
*
* Building blocks for web development
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015 - 2016
2015-11-16 11:40:01 -05:00
* @license MIT
*/
2015-09-17 23:11:18 -04:00
namespace Aviat\Ion\View;
2016-01-07 13:45:43 -05:00
use Aviat\Ion\Json;
2015-09-17 23:11:18 -04:00
use Aviat\Ion\View\HttpView;
2015-11-18 10:48:05 -05:00
use Aviat\Ion\View as BaseView;
2015-09-17 23:11:18 -04:00
/**
* View class to serialize Json
*/
2015-09-17 23:11:18 -04:00
class JsonView extends HttpView {
/**
* Response mime type
*
* @var string
*/
protected $contentType = 'application/json';
/**
* Set the output string
*
* @param mixed $string
2015-11-18 10:48:05 -05:00
* @return BaseView
2015-09-17 23:11:18 -04:00
*/
public function setOutput($string)
{
if ( ! is_string($string))
{
2016-01-07 13:45:43 -05:00
$string = Json::encode($string);
2015-09-17 23:11:18 -04:00
}
return parent::setOutput($string);
}
}
// End of JsonView.php