31 lines
		
	
	
		
			759 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			759 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace kernel;
 | |
| 
 | |
| use JetBrains\PhpStorm\NoReturn;
 | |
| 
 | |
| class Controller
 | |
| {
 | |
|     protected \Twig\Loader\FilesystemLoader $loader;
 | |
|     protected \Twig\Environment $twig;
 | |
|     protected CgView $cgView;
 | |
| 
 | |
|     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']]);
 | |
| 
 | |
|         $this->cgView = new CgView();
 | |
|         $this->cgView->viewPath = ROOT_DIR . "/views";
 | |
| 
 | |
|         $this->init();
 | |
|     }
 | |
| 
 | |
|     #[NoReturn] protected function redirect(string $url, int $code = 301): void
 | |
|     {
 | |
|         header('Location: ' . $url, true, $code);
 | |
|         exit;
 | |
|     }
 | |
| 
 | |
|     protected function init(){}
 | |
| } |