Skip to content

Commit

Permalink
Do not check publishing state for the backend view switch (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Feb 16, 2023
1 parent a69916d commit 49ee37c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/EventListener/BackendView/ArticleViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function getAvailableLanguages(PageModel $page): array
$masterRoot = $this->pageFinder->findMasterRootForPage($page);
$articleId = (int) ($page->rootId === $masterRoot->id ? $this->currentArticle->id : $this->currentArticle->languageMain);

foreach ($this->pageFinder->findAssociatedForPage($page, true) as $model) {
foreach ($this->pageFinder->findAssociatedForPage($page, true, null, false) as $model) {
$model->loadDetails();

$articles = $this->findArticlesForPage($model, $articleId);
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/BackendView/PageViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function getAvailableLanguages(PageModel $page): array
{
$options = [];

foreach ($this->pageFinder->findAssociatedForPage($page, true) as $model) {
foreach ($this->pageFinder->findAssociatedForPage($page, true, null, false) as $model) {
$model->loadDetails();
$options[$model->id] = $this->getLanguageLabel($model->language);
}
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/BackendView/ParentChildViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function getAvailableLanguages(PageModel $page)
return [];
}

foreach ($this->pageFinder->findAssociatedForPage($page, true) as $associated) {
foreach ($this->pageFinder->findAssociatedForPage($page, true, null, false) as $associated) {
$associated->loadDetails();
$model = $this->findRelatedForPageAndId($associated, $id);

Expand Down
10 changes: 6 additions & 4 deletions src/PageFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ public function findMasterRootForPage(PageModel $page): ?PageModel
/**
* @return array<PageModel>
*/
public function findAssociatedForPage(PageModel $page, bool $skipCurrent = false, array $rootPages = null): array
public function findAssociatedForPage(PageModel $page, bool $skipCurrent = false, array $rootPages = null, bool $publishedOnly = true): array
{
if ('root' === $page->type) {
return $this->findRootPagesForPage($page, $skipCurrent);
return $this->findRootPagesForPage($page, $skipCurrent, $publishedOnly);
}

if (null === $rootPages) {
$rootPages = $this->findRootPagesForPage($page, $skipCurrent);
$rootPages = $this->findRootPagesForPage($page, $skipCurrent, $publishedOnly);
}

$page->loadDetails();
Expand All @@ -117,7 +117,9 @@ public function findAssociatedForPage(PageModel $page, bool $skipCurrent = false
$values[] = $page->id;
}

$this->addPublishingConditions($columns, $t);
if ($publishedOnly) {
$this->addPublishingConditions($columns, $t);
}

return array_filter(
$this->findPages($columns, $values),
Expand Down

0 comments on commit 49ee37c

Please sign in to comment.