Skip to content
Snippets Groups Projects
Commit d00c40c4 authored by Matthieu Scarset's avatar Matthieu Scarset Committed by Nikolay Lobachev
Browse files

Issue #3281851: Support menu_manipulator for language filtering

parent 70ceff84
No related branches found
No related tags found
1 merge request!1Add support for menu_manipulator #3281851
......@@ -3,6 +3,7 @@
namespace Drupal\superfish\Plugin\Block;
use Drupal\Component\Utility\Html;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Menu\MenuActiveTrailInterface;
use Drupal\Core\Menu\MenuLinkTreeInterface;
......@@ -30,6 +31,13 @@ class SuperfishBlock extends SystemMenuBlock {
*/
protected $menuActiveTrail;
/**
* Drupal\Core\Extension\ModuleHandler definition.
*
* @var \Drupal\Core\Extension\ModuleHandler
*/
protected $moduleHandler;
/**
* Constructs a new SuperfishBlock.
*
......@@ -44,9 +52,10 @@ class SuperfishBlock extends SystemMenuBlock {
* @param \Drupal\Core\Menu\MenuActiveTrailInterface $menu_active_trail
* The active menu trail service.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MenuLinkTreeInterface $menu_tree, MenuActiveTrailInterface $menu_active_trail) {
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MenuLinkTreeInterface $menu_tree, MenuActiveTrailInterface $menu_active_trail, ModuleHandlerInterface $module_handler) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $menu_tree, $menu_active_trail);
$this->menuActiveTrail = $menu_active_trail;
$this->moduleHandler = $module_handler;
}
/**
......@@ -58,7 +67,8 @@ class SuperfishBlock extends SystemMenuBlock {
$plugin_id,
$plugin_definition,
$container->get('menu.link_tree'),
$container->get('menu.active_trail')
$container->get('menu.active_trail'),
$container->get('module_handler')
);
}
......@@ -1526,6 +1536,9 @@ class SuperfishBlock extends SystemMenuBlock {
['callable' => 'menu.default_tree_manipulators:checkAccess'],
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
];
if ($this->moduleHandler->moduleExists('menu_manipulator')) {
$manipulators[] = ['callable' => 'menu_manipulator.menu_tree_manipulators:filterTreeByCurrentLanguage'];
}
$tree = $this->menuTree->transform($tree, $manipulators);
// Unique HTML ID.
......
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