30 lines
712 B
PHP
30 lines
712 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Core;
|
|
|
|
final class View
|
|
{
|
|
public static function render(string $template, array $data = []): void
|
|
{
|
|
$templatePath = base_path('views/' . trim($template, '/') . '.php');
|
|
|
|
if (!is_file($templatePath)) {
|
|
http_response_code(500);
|
|
echo 'Template not found';
|
|
return;
|
|
}
|
|
|
|
extract($data, EXTR_SKIP);
|
|
|
|
$title = $title ?? 'Рыбсток';
|
|
$metaDescription = $metaDescription ?? '';
|
|
$metaKeywords = $metaKeywords ?? '';
|
|
$breadcrumbs = $breadcrumbs ?? [];
|
|
$showBackButton = $showBackButton ?? true;
|
|
|
|
require base_path('views/layouts/main.php');
|
|
}
|
|
}
|