first commit
Этот коммит содержится в:
44
src/core/View.php
Обычный файл
44
src/core/View.php
Обычный файл
@@ -0,0 +1,44 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
Ссылка в новой задаче
Block a user