function AnnouncementsFeedHooks::toolbarAlter

Implements hook_toolbar_alter().

File

core/modules/announcements_feed/src/Hook/AnnouncementsFeedHooks.php, line 84

Class

AnnouncementsFeedHooks
Hook implementations for announcements_feed.

Namespace

Drupal\announcements_feed\Hook

Code

public function toolbarAlter(&$items) {
    // As the "Announcements" link is shown already in the top toolbar bar, we
    // don't need it again in the administration menu tray, so hide it.
    if (!empty($items['administration']['tray'])) {
        $callable = function (array $element) {
            unset($element['administration_menu']['#items']['announcements_feed.announcement']);
            return $element;
        };
        $items['administration']['tray']['toolbar_administration']['#pre_render'][] = $callable;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.