dbms_primeidc/extdbms/lib/Core/Controller.php
2025-04-02 16:37:26 +09:00

45 lines
1.1 KiB
PHP

<?php
namespace lib\Core;
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Configs' . DIRECTORY_SEPARATOR . 'Constant.php';
use lib\Configs\View;
abstract class Controller
{
private ?View $_view = null;
private $_segments = [];
protected function __construct()
{
$this->_view = new View();
} //
final public function getView(): View
{
return $this->_view;
}
final public function __get($name)
{
return $this->getView()->$name;
}
final public function __set($name, $value)
{
$this->getView()->$name = $value;
}
final public function setSegments(array $segments)
{
$this->_segments = $segments;
}
final public function getSegments(string $key = ""): mixed
{
if ($key === "") {
return $this->_segments;
}
return array_key_exists($key, $this->_segments) ? $this->_segments[$key] : null;
}
public function render(string $path)
{
return $this->getView()->render($path);
}
} //Class