Upgraded Latte to version 3.

This commit is contained in:
Abel Hoogeveen 2023-03-28 09:21:59 +02:00
parent 5e19b1bd7a
commit fc3f73578a
3 changed files with 22 additions and 7 deletions

View File

@ -13,12 +13,11 @@
"fuzeworks/webcomponent": "~1.3.0",
"fuzeworks/authentication": "~1.3.0",
"fuzeworks/layout": "~1.3.0",
"latte/latte": "~2.5",
"latte/latte": "~3.0",
"almasaeed2010/adminlte": "^3"
},
"require-dev": {
"fuzeworks/tracycomponent": "~1.3.0",
"phpunit/phpunit": "^9"
"fuzeworks/tracycomponent": "~1.3.0"
},
"autoload": {
"psr-4": {

View File

@ -38,10 +38,10 @@ use FuzeWorks\Administration\Attributes\DisplayAttribute;
use FuzeWorks\Administration\Attributes\FooterCodeMethodAttribute;
use FuzeWorks\Administration\Attributes\IconAttribute;
use FuzeWorks\Administration\Attributes\PermissionAttribute;
use FuzeWorks\Administration\Exceptions\AdminPluginException;
use FuzeWorks\Authentication\AuthenticationPlugin;
use FuzeWorks\Authentication\Model\Session;
use FuzeWorks\Config;
use FuzeWorks\ConfigORM\ConfigORM;
use FuzeWorks\Controllers;
use FuzeWorks\Core;
use FuzeWorks\Event\LayoutLoadEvent;
@ -55,6 +55,7 @@ use FuzeWorks\Exception\FactoryException;
use FuzeWorks\Exception\HaltException;
use FuzeWorks\Exception\LayoutException;
use FuzeWorks\Exception\OutputException;
use FuzeWorks\Exception\PluginException;
use FuzeWorks\Exception\WebException;
use FuzeWorks\Factory;
use FuzeWorks\iPluginHeader;
@ -62,6 +63,7 @@ use FuzeWorks\Layout;
use FuzeWorks\Logger;
use FuzeWorks\Models;
use FuzeWorks\Output;
use FuzeWorks\Plugins;
use FuzeWorks\Priority;
use FuzeWorks\Resources;
use FuzeWorks\Router;
@ -91,9 +93,8 @@ class AdminPlugin implements iPluginHeader
/**
* @inheritDoc
* @throws EventException
* @throws FactoryException
* @throws ConfigException
* @throws AdminPluginException
*/
public function init()
{
@ -109,6 +110,18 @@ class AdminPlugin implements iPluginHeader
if (!$adminCFG->get('admin_enabled'))
return;
// Verify that authenticationPlugin is present
if (!class_exists('\FuzeWorks\Authentication\AuthenticationPlugin'))
throw new AdminPluginException("Could not load administration plugin. Missing dependency: AuthenticationPlugin.");
/** @var Plugins $plugins */
$plugins = Factory::getInstance("plugins");
try {
$this->authPlugin = $plugins->get('auth');
} catch (PluginException | EventException $e) {
throw new AdminPluginException("Could not load administration plugin. AuthenticationPlugin was not loaded.");
}
// Register the event
Events::addListener([$this, 'routeWebRequestEventListener'], 'routeWebRequestEvent', Priority::NORMAL);
@ -201,7 +214,6 @@ class AdminPlugin implements iPluginHeader
// Load the current session
/** @var Output $output */
$this->authPlugin = Factory::getInstance("plugins")->get('auth');
$output = Factory::getInstance("output");
// Redirect the user to login if they're not logged in

View File

@ -54,10 +54,14 @@ $configurator->addComponent(new \FuzeWorks\LayoutComponent());
// Add TracyComponent
$configurator->addComponent(new \FuzeWorks\TracyComponent());
// Add DatabaseComponent
$configurator->addComponent(new \FuzeWorks\DatabaseComponent());
// Debug related
$configurator->enableDebugMode();
$configurator->setDebugAddress('ALL');
$container = $configurator->createContainer();
$container->plugins->addPlugin(new \FuzeWorks\Authentication\AuthenticationPlugin());
$container->plugins->addPlugin(new \FuzeWorks\Administration\AdminPlugin());
return $container;