Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Add option to disable translation fallback in menus #1499

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Classes/Service/PageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class PageService implements SingletonInterface
* @param boolean $includeNotInMenu
* @param boolean $includeMenuSeparator
* @param boolean $disableGroupAccessCheck
* @param boolean $normalWhenNoLanguage
*
* @return array
*/
Expand All @@ -60,7 +61,8 @@ public function getMenu(
array $excludePages = [],
$includeNotInMenu = false,
$includeMenuSeparator = false,
$disableGroupAccessCheck = false
$disableGroupAccessCheck = false,
$normalWhenNoLanguage = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a couple of other patches which all try to change the method signature for getMenu which in turn affects any ViewHelper using menu functions. I'm extremely hesitant to change this bit unless it gets changed to a way that will prevent future signature changes, which means either:

  • Implementing a DTO that contains menu configuration instructions.
  • Or replacing this with whichever core method allows us to read a menu without rendering it as HTML.

But I don't think we should open the flood gates for this signature change because it's going to happen again and again, and the signature will become bloated. It's already pretty bad...

) {
$pageRepository = $this->getPageRepository();
$pageConstraints = $this->getPageConstraints($excludePages, $includeNotInMenu, $includeMenuSeparator);
Expand All @@ -72,8 +74,8 @@ public function getMenu(

static::$cachedMenus[$cacheKey] = array_filter(
$pageRepository->getMenu($pageUid, '*', 'sorting', $pageConstraints),
function($page) {
return $this->hidePageForLanguageUid($page) === false;
function($page) use ($normalWhenNoLanguage) {
return $this->hidePageForLanguageUid($page, -1, $normalWhenNoLanguage) === false;
}
);
}
Expand Down
11 changes: 10 additions & 1 deletion Classes/ViewHelpers/Menu/AbstractMenuViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ public function initializeArguments()
'Optional divider to insert between each menu item. Note that this does not mix well with automatic ' .
'rendering due to the use of an ul > li structure'
);
$this->registerArgument(
'normalWhenNoLanguage',
'boolean',
'If TRUE, a missing page overlay should be ignored',
false,
false
);
}

/**
Expand Down Expand Up @@ -420,14 +427,16 @@ public function getMenu($pageUid = null, $entryLevel = 0)
$showHiddenInMenu = (boolean) $this->arguments['showHiddenInMenu'];
$showAccessProtected = (boolean) $this->arguments['showAccessProtected'];
$includeSpacers = (boolean) $this->arguments['includeSpacers'];
$normalWhenNoLanguage = (boolean) $this->arguments['normalWhenNoLanguage'];
$excludePages = $this->processPagesArgument($this->arguments['excludePages']);

return $this->pageService->getMenu(
$pageUid,
$excludePages,
$showHiddenInMenu,
$includeSpacers,
$showAccessProtected
$showAccessProtected,
$normalWhenNoLanguage
);
}

Expand Down