microserviciile de register, login finalizate
This commit is contained in:
Regular → Executable
+25
-25
@@ -1,26 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace app\core;
|
||||
use app\core\middlewares\BaseMiddleware;
|
||||
|
||||
class Controller{
|
||||
public string $layout = 'main';
|
||||
public string $action = '';
|
||||
protected array $middlewares = [];
|
||||
|
||||
public function render($view, $params = []){
|
||||
return Application::$app->view->renderView($view, $params);
|
||||
}
|
||||
|
||||
public function setLayout($layout){
|
||||
$this->layout = $layout;
|
||||
}
|
||||
|
||||
public function registerMiddleware(BaseMiddleware $middleware){
|
||||
$this->middlewares[] = $middleware;
|
||||
}
|
||||
|
||||
public function getMiddlewares(){
|
||||
return $this->middlewares;
|
||||
}
|
||||
<?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;}
|
||||
}
|
||||
Reference in New Issue
Block a user