By alexpott on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.5.x
Introduced in version:
8.5.0
Issue links:
Description:
The menu active trail service has been removed from SystemMenuBlock.
If you maintain a custom or contributed module that has a block plugin that extends \Drupal\system\Plugin\Block\SystemMenuBlock you might need to update it. If the plugin is using the service or the $menuActiveTrail property you will need to make changes. Ideally code should not extend from concrete plugin classes as these are internal as per https://www.drupal.org/core/d8-bc-policy but it is possible to make the code more robust by removing any constructor overrides and overriding the ::create() method in your plugin. For example:
/**
* The active menu trail service.
*
* @var \Drupal\Core\Menu\MenuActiveTrailInterface
*/
protected $menuActiveTrail;
/**
* {@inheritdoc}
*/
public static function create($config, $plugin_id, $def, $container) {
$static = parent::create($config, $plugin_id, $def, $container);
$static->setMenuActiveTrail($container->get('menu.active_trail'));
return $static;
}
/**
* Sets the menu active trail service.
*
* @param \Drupal\Core\Menu\MenuActiveTrailInterface $menu_active_trail
* The menu active trail service.
*/
protected function setMenuActiveTrail(MenuActiveTrailInterface $menu_active_trail) {
$this->menuActiveTrail = $menu_active_trail;
}
Impacts:
Module developers