42 lines
1001 B
PHP
42 lines
1001 B
PHP
<?php
|
|
|
|
namespace lib\Core;
|
|
|
|
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Configs' . DIRECTORY_SEPARATOR . 'Constant.php';
|
|
|
|
use lib\Configs\View;
|
|
use lib\Http\Request;
|
|
|
|
abstract class Controller
|
|
{
|
|
private ?View $_view = null;
|
|
private ?Request $_request = null;
|
|
protected function __construct() {} //
|
|
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);
|
|
}
|
|
final public function getRequest(): Request
|
|
{
|
|
if ($this->_request === null) {
|
|
$this->_request = new Request();
|
|
}
|
|
return $this->_request;
|
|
}
|
|
} //Class
|