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} -