Implemented account system

This commit is contained in:
Michel Fedde 2024-07-05 16:50:53 +02:00
parent 51c20b55a0
commit ace0de4063
25 changed files with 1543 additions and 40 deletions

View file

@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace GamesShop\Templates;
use GamesShop\Login\UserPermission;
final class NavigationHeader
{
public function __construct(
public readonly string $title,
public readonly string $link,
public readonly UserPermission $minimumPermission,
)
{
}
}

View file

@ -3,6 +3,7 @@ declare(strict_types=1);
namespace GamesShop\Templates;
use GamesShop\Login\LoginHandler;
use GamesShop\Paths;
use League\Plates\Engine;
@ -12,11 +13,13 @@ final class TemplateEngine extends Engine
public function __construct(
private ResourceIndex $resourceIndex,
LoginHandler $loginHandler,
)
{
parent::__construct(self::TEMPLATES_PATH, 'php');
$this->addData([
'resources' => $this->resourceIndex,
'activeUser' => $loginHandler->isLoggedIn() ? $loginHandler->getCurrentUser() : null,
]);
}
@ -24,4 +27,8 @@ final class TemplateEngine extends Engine
{
return parent::render("pages/$page", $data);
}
public function renderErrorPage(int $error) {
return self::renderPage('error', [ 'errorCode' => $error ]);
}
}