HummingBirdAnimeClient/src/Aviat/Ion/View.php

101 lines
1.5 KiB
PHP
Raw Normal View History

2015-09-17 23:11:18 -04:00
<?php
namespace Aviat\Ion;
use Aviat\Ion\Di\ContainerInterface;
abstract class View {
use Di\ContainerAware;
2015-10-01 16:02:51 -04:00
use \Aviat\Ion\StringWrapper;
2015-09-17 23:11:18 -04:00
/**
* HTTP response Object
*
* @var Aura\Web\Response
*/
protected $response;
/**
* Response mime type
*
* @var string
*/
protected $contentType = '';
/**
* String of response to be output
*
2015-10-01 16:02:51 -04:00
* @var S
2015-09-17 23:11:18 -04:00
*/
2015-10-01 16:02:51 -04:00
protected $output;
2015-09-17 23:11:18 -04:00
/**
* Constructor
*
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
$this->setContainer($container);
$this->response = $container->get('response');
}
/**
* Send output to client
*/
public function __destruct()
{
$this->output();
}
/**
* Set the output string
*
* @param string $string
* @return View
*/
public function setOutput($string)
{
2015-10-01 16:02:51 -04:00
$this->output = $this->string($string);
2015-09-17 23:11:18 -04:00
return $this;
}
/**
* Append additional output
*
* @param string $string
* @return View
*/
public function appendOutput($string)
{
2015-10-01 16:02:51 -04:00
$this->output = $this->string($this->output)->append($string);
2015-09-17 23:11:18 -04:00
return $this;
}
/**
* Get the current output string
*
* @return string
*/
public function getOutput()
{
2015-10-01 16:02:51 -04:00
return $this->string($this->output)->__toString();
2015-09-17 23:11:18 -04:00
}
/**
* 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');
}
}
// End of View.php