Files
FACULTATE-KNOW_YOUR_FOOD/knowyourfood/core/Controller.php
T

26 lines
969 B
PHP
Executable File

<?php
namespace app\core;
abstract class Controller{
protected string $view = "";
protected string $title = "";
protected string $layout = "";
protected ?Model $model = NULL;
public function render(): string
{
Application::$app->view->setLayout($this->layout);
Application::$app->view->setTitle($this->title);
Application::$app->view->setView($this->view);
Application::$app->view->setModel($this->model);
return Application::$app->view->render();
}
protected static abstract function setControllerParams(string $title, string $view, string $layout, ?Model $model);
public function setView(string $view): void {$this->view = $view;}
public function setTitle(string $title): void {$this->title = $title;}
public function setLayout(string $layout): void {$this->layout = $layout;}
public function setModel(?Model $model): void {$this->model = $model;}
}