Skip to content

Commit

Permalink
fix: page types
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny committed Dec 7, 2023
1 parent 7de1aa9 commit 00308bb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Generator/Homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function generate(): void
$page->setType(Type::HOMEPAGE->value);
// collects all pages
$subPages = $this->builder->getPages()->filter(function (Page $page) use ($language) {
return $page->getType() == Type::PAGE
return $page->getType() == Type::PAGE->value
&& $page->isVirtual() === false
&& $page->getVariable('exclude') !== true
&& $page->getVariable('language') == $language;
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function generate(): void

// filters list pages (home, sections and terms)
$filteredPages = $this->builder->getPages()->filter(function (Page $page) {
return \in_array($page->getType(), [Type::HOMEPAGE, Type::SECTION, Type::TERM]);
return \in_array($page->getType(), [Type::HOMEPAGE->value, Type::SECTION->value, Type::TERM->value]);
});
/** @var Page $page */
foreach ($filteredPages as $page) {
Expand Down
4 changes: 2 additions & 2 deletions src/Renderer/Extension/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ public function filterBy(PagesCollection $pages, string $variable, string $value
// is a dedicated getter exists?
$method = 'get' . ucfirst($variable);
if (method_exists($page, $method) && $page->$method() == $value) {
return $page->getType() == Type::PAGE && !$page->isVirtual() && true;
return $page->getType() == Type::PAGE->value && !$page->isVirtual() && true;
}
// or a classic variable
if ($page->getVariable($variable) == $value) {
return $page->getType() == Type::PAGE && !$page->isVirtual() && true;
return $page->getType() == Type::PAGE->value && !$page->isVirtual() && true;
}
});

Expand Down

0 comments on commit 00308bb

Please sign in to comment.