kernel update
This commit is contained in:
@ -10,6 +10,8 @@ class CgView
|
||||
public array $varToLayout = [];
|
||||
public bool|string $layout = false;
|
||||
|
||||
protected array $metaArr = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -34,14 +36,37 @@ class CgView
|
||||
$this->varToLayout[$key] = $value;
|
||||
}
|
||||
|
||||
private function createContent(string $view, array $data = []): false|string
|
||||
public function setTitle(string $title): void
|
||||
{
|
||||
$this->addVarToLayout('title', $title);
|
||||
}
|
||||
|
||||
public function setMeta(array $meta): void
|
||||
{
|
||||
foreach ($meta as $key => $value){
|
||||
$this->metaArr[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getMeta(): string
|
||||
{
|
||||
$meta = "";
|
||||
foreach ($this->metaArr as $key => $value){
|
||||
$meta .= "<meta name='$key' content='$value'>";
|
||||
}
|
||||
|
||||
return $meta;
|
||||
}
|
||||
|
||||
private function createContent(string $viewFile, array $data = []): false|string
|
||||
{
|
||||
ob_start();
|
||||
$view = $this;
|
||||
foreach ($data as $key => $datum) {
|
||||
${"$key"} = $datum;
|
||||
}
|
||||
|
||||
include($this->viewPath . $view);
|
||||
include($this->viewPath . $viewFile);
|
||||
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
@ -50,6 +75,10 @@ class CgView
|
||||
|
||||
$file_content = $content;
|
||||
|
||||
if (!isset($title)){
|
||||
$title = "No Title";
|
||||
}
|
||||
|
||||
$layoutPath = $this->viewPath;
|
||||
|
||||
if ($this->layout) {
|
||||
|
Reference in New Issue
Block a user