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/webcomponent": "~1.3.0",
"fuzeworks/authentication": "~1.3.0", "fuzeworks/authentication": "~1.3.0",
"fuzeworks/layout": "~1.3.0", "fuzeworks/layout": "~1.3.0",
"latte/latte": "~2.5", "latte/latte": "~3.0",
"almasaeed2010/adminlte": "^3" "almasaeed2010/adminlte": "^3"
}, },
"require-dev": { "require-dev": {
"fuzeworks/tracycomponent": "~1.3.0", "fuzeworks/tracycomponent": "~1.3.0"
"phpunit/phpunit": "^9"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

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

View File

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