Mercurial > hg > isophonics-drupal-site
view core/modules/toolbar/src/Menu/ToolbarMenuLinkTree.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children |
line wrap: on
line source
<?php namespace Drupal\toolbar\Menu; use Drupal\Core\Menu\MenuLinkTree; /** * Extends MenuLinkTree to add specific theme suggestions for the toolbar. */ class ToolbarMenuLinkTree extends MenuLinkTree { /** * {@inheritdoc} */ public function build(array $tree, $level = 0) { if ($level == 0) { if (!$tree) { return []; } $build = parent::build($tree, $level); /** @var \Drupal\Core\Menu\MenuLinkInterface $link */ $first_link = reset($tree)->link; // Get the menu name of the first link. $menu_name = $first_link->getMenuName(); // Add a more specific theme suggestion to differentiate this rendered // menu from others. $build['#menu_name'] = $menu_name; $build['#theme'] = 'menu__toolbar__' . strtr($menu_name, '-', '_'); return $build; } else { return parent::build($tree, $level); } } }