Routing, static views
This commit is contained in:
@@ -15,6 +15,7 @@ abstract class Head extends View {
|
||||
function __construct($document) {
|
||||
parent::__construct($document);
|
||||
$this->sources = array();
|
||||
$this->searchable = false;
|
||||
$this->metas = $this->initMetas();
|
||||
$this->rawFields = $this->initRawFields();
|
||||
$this->title = $this->initTitle();
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Elements;
|
||||
|
||||
use External\PHPMailer\Exception;
|
||||
|
||||
abstract class View extends StaticView {
|
||||
|
||||
private Document $document;
|
||||
@@ -25,6 +27,21 @@ abstract class View extends StaticView {
|
||||
public function isSearchable() { return $this->searchable; }
|
||||
public function getReference() { return $this->reference; }
|
||||
|
||||
protected function load(string $viewClass) : string {
|
||||
try {
|
||||
$reflectionClass = new \ReflectionClass($viewClass);
|
||||
if ($reflectionClass->isSubclassOf(View::class) && $reflectionClass->isInstantiable()) {
|
||||
$view = $reflectionClass->newInstanceArgs(array($this->getDocument()));
|
||||
$view->loadView();
|
||||
return $view;
|
||||
}
|
||||
} catch(\ReflectionException $e) {
|
||||
error_log($e->getMessage());
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private function loadLanguageModules() {
|
||||
$lang = $this->document->getUser()->getLanguage();
|
||||
foreach($this->langModules as $langModule) {
|
||||
|
||||
Reference in New Issue
Block a user