Skip to content
Snippets Groups Projects
Commit abd8e457 authored by Tim Diels's avatar Tim Diels
Browse files

Issue #3221019 by tim-diels, ilya.no, gaurav.bajpai: Config "Expand all menu links" is not handled

parent ce915e6d
No related branches found
No related tags found
1 merge request!12Add schema and copy code from system menu block to fix expand all menu links
Pipeline #147805 passed
......@@ -6,3 +6,16 @@ domain_menu_access.settings:
label: 'Menu enabled'
sequence:
type: string
block.settings.domain_access_menu_block:*:
type: block_settings
label: 'Menu block'
mapping:
level:
type: integer
label: 'Starting level'
depth:
type: integer
label: 'Maximum number of levels'
expand_all_items:
type: boolean
label: 'Expand all items'
......@@ -6,6 +6,7 @@ use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Menu\MenuActiveTrailInterface;
use Drupal\Core\Menu\MenuLinkTreeInterface;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\system\Plugin\Block\SystemMenuBlock;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -75,7 +76,15 @@ class DomainMenuAccessMenuBlock extends SystemMenuBlock implements ContainerFact
if (!$this->isDomainRestricted($menu_name)) {
return parent::build();
}
$parameters = $this->menuTree->getCurrentRouteMenuTreeParameters($menu_name);
if ($this->configuration['expand_all_items']) {
$parameters = new MenuTreeParameters();
$active_trail = $this->menuActiveTrail->getActiveTrailIds($menu_name);
$parameters->setActiveTrail($active_trail);
}
else {
$parameters = $this->menuTree->getCurrentRouteMenuTreeParameters($menu_name);
}
// Adjust the menu tree parameters based on the block's configuration.
$level = $this->configuration['level'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment