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

76 lines
1.2 KiB
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;
use Aura\Web\ResponseSender;
use Aviat\Ion\View as BaseView;
/**
* Base view class for Http output
*/
2015-09-17 23:11:18 -04:00
class HttpView extends BaseView {
2015-09-17 23:11:18 -04:00
/**
* Do a redirect
*
2015-09-17 23:11:18 -04:00
* @param string $url
* @param int $code
* @return void
*/
public function redirect($url, $code)
{
$this->response->redirect->to($url, $code);
2016-01-08 15:53:50 -05:00
}
/**
* Set the status code of the request
*
* @param int $code
* @return HttpView
*/
public function setStatusCode($code)
{
$this->response->status->setCode($code);
$this->response->status->setVersion(1.1);
return $this;
}
/**
* Send output to client
*
* @return void
*/
public function send()
{
$this->hasRendered = TRUE;
$this->output();
}
/**
* Send the appropriate response
*
* @return void
*/
protected function output()
{
$content =& $this->response->content;
$content->set($this->output);
$content->setType($this->contentType);
$content->setCharset('utf-8');
$sender = new ResponseSender($this->response);
$sender->__invoke();
}
2015-09-17 23:11:18 -04:00
}