From 12e74b120ff279832cf731f12eeaeb32cdd3db31 Mon Sep 17 00:00:00 2001 From: Robert Durica Date: Mon, 14 Aug 2023 21:39:05 +0200 Subject: [PATCH] Navbar, acl, extra packages --- src/app/Model/Constant/Resource.php | 18 + src/app/Model/Manager/RulesManager.php | 37 + src/app/Presenter/HomePresenter.php | 30 +- src/app/Presenter/SignPresenter.php | 4 +- .../Presenter/templates/Home/default.latte | 63 +- src/app/Presenter/templates/Home/rules.latte | 14 + src/app/Presenter/templates/navbar.latte | 16 +- src/composer.json | 8 +- src/composer.lock | 1527 ----------------- src/config/services.neon | 6 + 10 files changed, 181 insertions(+), 1542 deletions(-) create mode 100644 src/app/Model/Constant/Resource.php create mode 100644 src/app/Model/Manager/RulesManager.php create mode 100644 src/app/Presenter/templates/Home/rules.latte delete mode 100644 src/composer.lock diff --git a/src/app/Model/Constant/Resource.php b/src/app/Model/Constant/Resource.php new file mode 100644 index 0000000..a95e446 --- /dev/null +++ b/src/app/Model/Constant/Resource.php @@ -0,0 +1,18 @@ + + * @copyright Copyright (c) 2023, Robert Durica + */ +final class Resource +{ + /** Edit game rules. */ + public const RULES = 'rules'; +} diff --git a/src/app/Model/Manager/RulesManager.php b/src/app/Model/Manager/RulesManager.php new file mode 100644 index 0000000..63ac02d --- /dev/null +++ b/src/app/Model/Manager/RulesManager.php @@ -0,0 +1,37 @@ + + * @copyright Copyright (c) 2023, Robert Durica + */ +final class RulesManager extends Manager +{ + /** @var string Table name. */ + private const TABLE = 'rules'; + + /** @inheritDoc */ + protected function getTableName(): string + { + return self::TABLE; + } + + /** + * Get rules. + * + * @return ActiveRow|null + */ + public function findRules(): ?ActiveRow + { + return $this->find()->fetch(); + } +} diff --git a/src/app/Presenter/HomePresenter.php b/src/app/Presenter/HomePresenter.php index c7ab855..a34fae0 100644 --- a/src/app/Presenter/HomePresenter.php +++ b/src/app/Presenter/HomePresenter.php @@ -4,13 +4,41 @@ namespace App\Presenter; +use App\Model\Constant\Resource; +use App\Model\Manager\RulesManager; +use Nepada\SecurityAnnotations\Annotations\Allowed; +use Nepada\SecurityAnnotations\SecurityAnnotations; +use Nette\DI\Attributes\Inject; +use Rdurica\Core\Constant\Privileges; use Rdurica\Core\Presenter\Presenter; use Rdurica\Core\Presenter\RequireLoggedUser; use Rdurica\Core\Presenter\SetMdbTemplateLayout; - +/** + * HomePresenter. + * + * @package App\Presenter + * @author Robert Durica + * @copyright Copyright (c) 2023, Robert Durica + */ final class HomePresenter extends Presenter { use SetMdbTemplateLayout; use RequireLoggedUser; + use SecurityAnnotations; + + #[Inject] + public RulesManager $rulesManager; + + /** + * Rules page. + * + * @return void + */ + #[Allowed(resource: Resource::RULES, privilege: Privileges::VIEW)] + public function renderRules(): void + { + $data = $this->rulesManager->findRules(); + $this->getTemplate()->data = $data; + } } diff --git a/src/app/Presenter/SignPresenter.php b/src/app/Presenter/SignPresenter.php index d7796ee..02450d8 100644 --- a/src/app/Presenter/SignPresenter.php +++ b/src/app/Presenter/SignPresenter.php @@ -35,6 +35,4 @@ public function createComponentLoginForm(): LoginForm { return $this->loginForm->create(); } - - -} \ No newline at end of file +} diff --git a/src/app/Presenter/templates/Home/default.latte b/src/app/Presenter/templates/Home/default.latte index 836f682..34a879a 100644 --- a/src/app/Presenter/templates/Home/default.latte +++ b/src/app/Presenter/templates/Home/default.latte @@ -1,11 +1,62 @@ {block navbar}{include './../navbar.latte'}{/block} {block content} -