Initial Kaffeekasse SaaS restart
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
final class View
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $rootPath,
|
||||
private readonly array $shared = []
|
||||
) {
|
||||
}
|
||||
|
||||
public function render(string $template, array $data = []): void
|
||||
{
|
||||
$templateFile = $this->rootPath . '/resources/views/' . $template . '.php';
|
||||
|
||||
if (!is_file($templateFile)) {
|
||||
http_response_code(500);
|
||||
echo 'View not found: ' . htmlspecialchars($template, ENT_QUOTES, 'UTF-8');
|
||||
return;
|
||||
}
|
||||
|
||||
$shared = $this->shared;
|
||||
|
||||
extract($shared, EXTR_SKIP);
|
||||
extract($data, EXTR_SKIP);
|
||||
|
||||
require $templateFile;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user