Skip to content

Commit

Permalink
added: new API feature 'setting' e.g. $genug->setting->notFoundPageId
Browse files Browse the repository at this point in the history
  • Loading branch information
d4s6 committed Nov 22, 2022
1 parent c0c3cdd commit 775377c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
4 changes: 3 additions & 1 deletion genug.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
EntityNotFound as PageEntityNotFound,
Repository as PageRepository,
};
use genug\Setting\Setting;
use genug\Lib\EntityAndIdCache;

use const genug\Setting\ {
Expand Down Expand Up @@ -58,7 +59,8 @@
$pages,
$requestedPage,
$homePage,
$groups
$groups,
new Setting()
);
})();

Expand Down
4 changes: 3 additions & 1 deletion genug_core/genug/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
RepositoryInterface as PageRepositoryInterface,
Entity as PageEntity
};
use genug\Setting\Setting;

/**
*
Expand All @@ -23,7 +24,8 @@ public function __construct(
public readonly PageRepositoryInterface $pages,
public readonly PageEntity $requestedPage,
public readonly PageEntity $homePage,
public readonly GroupRepositoryInterface $groups
public readonly GroupRepositoryInterface $groups,
public readonly Setting $setting
) {
}
}
26 changes: 26 additions & 0 deletions genug_core/genug/setting/setting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace genug\Setting;

use const genug\Setting\{
MAIN_GROUP_ID,
HOME_PAGE_ID,
HTTP_404_PAGE_ID,
};

/**
*
* @author David Ringsdorf http://davidringsdorf.de
* @license MIT License
*/
class Setting
{
public function __construct(
public readonly string $homePageId = HOME_PAGE_ID,
public readonly string $notFoundPageId = HTTP_404_PAGE_ID,
public readonly string $mainGroupId = MAIN_GROUP_ID,
) {
}
}
2 changes: 1 addition & 1 deletion genug_user/view/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<h1>all pages</h1>
<ul>
<?php foreach ($genug->pages as $page): ?>
<?php if ((string) $page->id !== \genug\Setting\HTTP_404_PAGE_ID): ?>
<?php if ((string) $page->id !== $genug->setting->notFoundPageId): ?>
<li>
<a href="<?= $page->id ?>"<?php if ($page === $genug->requestedPage) {
echo ' aria-current="page"';
Expand Down

0 comments on commit 775377c

Please sign in to comment.