46 lines
1.0 KiB
PHP
46 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace lib\Core;
|
|
|
|
use lib\Configs\Config;
|
|
use lib\Configs\View;
|
|
|
|
abstract class Controller
|
|
{
|
|
private ?Config $_config = null;
|
|
private ?View $_view = null;
|
|
private $_segments = [];
|
|
protected function __construct()
|
|
{
|
|
$this->_config = new Config();
|
|
$this->_view = new View();
|
|
} //
|
|
final public function getConfig(): Config
|
|
{
|
|
return $this->_config;
|
|
}
|
|
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;
|
|
}
|
|
final public function __get($name)
|
|
{
|
|
return $this->_view->$name;
|
|
}
|
|
final public function __set($name, $value)
|
|
{
|
|
$this->_view->$name = $value;
|
|
}
|
|
public function render($file)
|
|
{
|
|
return $this->_view->render($file);
|
|
}
|
|
} //Class
|