47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace lib\Core;
|
|
|
|
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Configs' . DIRECTORY_SEPARATOR . 'Constant.php';
|
|
|
|
use lib\Configs\View;
|
|
use lib\Http\Redirect;
|
|
use lib\Http\Request;
|
|
use lib\Http\Session;
|
|
use Lib\Http\Url;
|
|
|
|
abstract class Controller
|
|
{
|
|
private ?View $_view = null;
|
|
final protected ?Url $url = null;
|
|
final protected ?Session $session = null;
|
|
final protected ?Redirect $redirect = null;
|
|
final protected ?Request $request = null;
|
|
protected function __construct()
|
|
{
|
|
$this->url = new Url();
|
|
$this->session = new Session();
|
|
$this->redirect = new Redirect($this->session);
|
|
$this->request = new Request();
|
|
} //
|
|
final public function __get($name)
|
|
{
|
|
return $this->getView()->$name;
|
|
}
|
|
final public function __set($name, $value)
|
|
{
|
|
$this->getView()->$name = $value;
|
|
}
|
|
final public function getView(): View
|
|
{
|
|
if ($this->_view === null) {
|
|
$this->_view = new View();
|
|
}
|
|
return $this->_view;
|
|
}
|
|
public function render(string $path)
|
|
{
|
|
return $this->getView()->render($path);
|
|
}
|
|
} //Class
|