- cleaned up some code
- added DataLoader - added assetDir - splitted modules and controller namespace
This commit is contained in:
parent
d3d889dc4c
commit
21977588d8
18 changed files with 263 additions and 41 deletions
25
src/Venom/Venom.php
Normal file → Executable file
25
src/Venom/Venom.php
Normal file → Executable file
|
|
@ -32,6 +32,8 @@ class Venom
|
|||
|
||||
public function run(): void
|
||||
{
|
||||
$arguments = ArgumentHandler::get();
|
||||
$arguments->setItem(ErrorHandler::ERROR_KEY, false);
|
||||
// we need to load the current controller and the current start template.
|
||||
// after this we can start the renderer
|
||||
if (Config::getInstance()->isRouterEnabled()) {
|
||||
|
|
@ -45,7 +47,10 @@ class Venom
|
|||
}
|
||||
$registry = Registry::getInstance();
|
||||
$registry->getLang()->initLang();
|
||||
$registry->getSeo()->loadSite();
|
||||
// if site is errored then dont load via SEO
|
||||
if (!$arguments->getItem(ErrorHandler::ERROR_KEY)) {
|
||||
$registry->getSeo()->loadSite();
|
||||
}
|
||||
$this->renderer->init($this->findController());
|
||||
$this->renderer->render();
|
||||
}
|
||||
|
|
@ -68,7 +73,16 @@ class Venom
|
|||
{
|
||||
$cl = ArgumentHandler::get()->getItem('cl');
|
||||
if ($cl !== null && isset($this->controllers[$cl])) {
|
||||
return $this->controllers[$cl];
|
||||
return $this->loadController($this->controllers[$cl]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function loadController($controllerClass): ?RenderController
|
||||
{
|
||||
$controller = new $controllerClass;
|
||||
if ($controller instanceof RenderController && $controller->register()) {
|
||||
return $controller;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -85,12 +99,7 @@ class Venom
|
|||
|
||||
public function initControllers(array $controllers): void
|
||||
{
|
||||
foreach ($controllers as $key => $controllerClass) {
|
||||
$controller = new $controllerClass;
|
||||
if ($controller instanceof RenderController && $controller->register()) {
|
||||
$this->controllers[$key] = $controller;
|
||||
}
|
||||
}
|
||||
$this->controllers = $controllers;
|
||||
}
|
||||
|
||||
public function addRouter(string $name, Router $router): void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue