Maslosoft Miniview API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
<?php
/**
* This software package is licensed under `AGPL, Commercial` license[s].
*
* @package maslosoft/miniview
* @license AGPL, Commercial
*
* @copyright Copyright (c) Peter Maselkowski <pmaselkowski@gmail.com>
*
* @link http://maslosoft.com/miniview/
*/
namespace Maslosoft\MiniView\Renderers;
use Maslosoft\MiniView\Interfaces\OwnerAwareInterface;
use Maslosoft\MiniView\Interfaces\OwnerForwarderInterface;
use Maslosoft\MiniView\Interfaces\ViewRendererInterface;
/**
* PhpRenderer
*
* @author Piotr Maselkowski <pmaselkowski at gmail.com>
*/
class PhpRenderer implements ViewRendererInterface, OwnerAwareInterface, OwnerForwarderInterface
{
use \Maslosoft\MiniView\Traits\OwnerAwareTrait,
\Maslosoft\MiniView\Traits\OwnerForwarderTrait;
/**
* Render php file
* @param string $_viewFile_
* @param mixed $_data_
* @param bool $_return_
* @return string
*/
public function render($_viewFile_, $_data_, $_return_ = false)
{
// we use special variable names here to avoid conflict when extracting data
if (is_array($_data_))
{
extract($_data_, EXTR_PREFIX_SAME, 'data');
}
else
{
$data = $_data_;
}
if ($_return_)
{
ob_start();
ob_implicit_flush(false);
require($_viewFile_);
return ob_get_clean();
}
else
{
require($_viewFile_);
}
}
}
API documentation generated by ApiGen