igfs/kernel/Controller.php

31 lines
759 B
PHP
Raw Normal View History

2024-07-12 11:31:04 +03:00
<?php
namespace kernel;
2024-07-24 17:22:59 +03:00
use JetBrains\PhpStorm\NoReturn;
2024-07-12 11:31:04 +03:00
class Controller
{
protected \Twig\Loader\FilesystemLoader $loader;
protected \Twig\Environment $twig;
2024-07-24 17:22:59 +03:00
protected CgView $cgView;
2024-07-12 11:31:04 +03:00
public function __construct()
{
$this->loader = new \Twig\Loader\FilesystemLoader(ROOT_DIR . $_ENV['VIEWS_PATH']);
$this->twig = new \Twig\Environment($this->loader, ['cache' => ROOT_DIR . $_ENV['VIEWS_CACHE_PATH']]);
2024-07-24 17:22:59 +03:00
$this->cgView = new CgView();
$this->cgView->viewPath = ROOT_DIR . "/views";
$this->init();
2024-07-12 11:31:04 +03:00
}
2024-07-24 14:07:45 +03:00
2024-07-24 17:22:59 +03:00
#[NoReturn] protected function redirect(string $url, int $code = 301): void
2024-07-24 14:07:45 +03:00
{
2024-07-24 17:22:59 +03:00
header('Location: ' . $url, true, $code);
exit;
2024-07-24 14:07:45 +03:00
}
2024-07-24 17:22:59 +03:00
protected function init(){}
2024-07-12 11:31:04 +03:00
}