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

35 lines
497 B
PHP
Raw Normal View History

2015-09-17 23:11:18 -04:00
<?php
namespace Aviat\Ion\View;
use Aviat\Ion\View\HttpView;
/**
* 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
* @return View
*/
public function setOutput($string)
{
if ( ! is_string($string))
{
$string = json_encode($string);
}
return parent::setOutput($string);
}
}
// End of JsonView.php