Erster Stand des mvc-Frameworks
This commit is contained in:
46
rendering/View/StandardView.php
Normal file
46
rendering/View/StandardView.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by CS medien- & kommunikationssysteme.
|
||||
* @author Christian Steinle
|
||||
* @date 03.08.2016
|
||||
*
|
||||
* @copyright CS medien- & kommunikationssysteme (http://www.steinle-computer.de)
|
||||
*/
|
||||
|
||||
namespace View;
|
||||
|
||||
|
||||
class StandardView
|
||||
{
|
||||
const TPL_PATH = PATH_TPL;
|
||||
|
||||
protected $template = '';
|
||||
|
||||
protected $data = array();
|
||||
|
||||
public function __construct(array $data, $template)
|
||||
{
|
||||
$this->setTemplate($template);
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
private function setTemplate($template)
|
||||
{
|
||||
if (file_exists(static::TPL_PATH . mb_strtolower($template) . '.phtml'))
|
||||
{
|
||||
$this->template = static::TPL_PATH . mb_strtolower($template) . '.phtml';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function render()
|
||||
{
|
||||
ob_start();
|
||||
include($this->template);
|
||||
$pageContent = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $pageContent;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user