45 строки
738 B
PHP
45 строки
738 B
PHP
<?php
|
|
|
|
namespace MyApp\Core;
|
|
|
|
class View
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
public $title = '';
|
|
|
|
public function json($data)
|
|
{
|
|
}
|
|
|
|
public function render($template)
|
|
{
|
|
/* @var \App $app */
|
|
global $app;
|
|
|
|
$fileName = $app->config->getSrcDir().'/templates/'.$template.'.tpl.php';
|
|
|
|
if (file_exists($fileName)) {
|
|
ob_start();
|
|
require $fileName;
|
|
ob_end_flush();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param string $title
|
|
*
|
|
* @return View
|
|
*/
|
|
public function setTitle(string $title)
|
|
{
|
|
/* @var \App $app */
|
|
global $app;
|
|
|
|
$this->title = $title.' — '.$app->config->getSiteName();
|
|
|
|
return $this;
|
|
}
|
|
}
|