diff --git a/core/modules/system/src/Plugin/Block/SystemMenuBlock.php b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php index 748a4f5..9adce5b 100644 --- a/core/modules/system/src/Plugin/Block/SystemMenuBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Block\BlockBase; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Menu\MenuActiveTrailInterface; use Drupal\Core\Menu\MenuLinkTreeInterface; @@ -44,6 +45,11 @@ class SystemMenuBlock extends BlockBase implements ContainerFactoryPluginInterfa protected $menuActiveTrail; /** + * @var \Drupal\Core\Extension\ModuleHandlerInterface. + */ + protected $moduleHandler; + + /** * Constructs a new SystemMenuBlock. * * @param array $configuration @@ -56,11 +62,14 @@ class SystemMenuBlock extends BlockBase implements ContainerFactoryPluginInterfa * The menu tree service. * @param \Drupal\Core\Menu\MenuActiveTrailInterface $menu_active_trail * The active menu trail service. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MenuLinkTreeInterface $menu_tree, MenuActiveTrailInterface $menu_active_trail) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MenuLinkTreeInterface $menu_tree, MenuActiveTrailInterface $menu_active_trail, ModuleHandlerInterface $module_handler) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->menuTree = $menu_tree; $this->menuActiveTrail = $menu_active_trail; + $this->moduleHandler = $module_handler; } /** @@ -72,7 +81,8 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $container->get('menu.link_tree'), - $container->get('menu.active_trail') + $container->get('menu.active_trail'), + $container->get('module_handler') ); } @@ -143,14 +153,16 @@ public function getOperationLinks() { $menu = $this->getDerivativeId(); $links = array(); - $links['menu-edit'] = array( - 'title' => $this->t('Edit menu'), - 'route_name' => 'entity.menu.edit_form', - 'route_parameters' => array( - 'menu' => $menu, - ), - 'weight' => 50, - ); + if ($this->moduleHandler->moduleExists('menu_ui')) { + $links['menu-edit'] = array( + 'title' => $this->t('Edit menu'), + 'route_name' => 'entity.menu.edit_form', + 'route_parameters' => array( + 'menu' => $menu, + ), + 'weight' => 50, + ); + } return $links; } diff --git a/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php b/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php index 5df82d6..c1dceaf 100644 --- a/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php +++ b/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php @@ -26,7 +26,7 @@ class SystemMenuBlockTest extends DrupalUnitTestBase { * * @var array */ - public static $modules = array('system', 'block', 'user'); + public static $modules = array('system', 'block', 'user', 'menu_ui'); protected function setUp() { parent::setUp();