AnnouncementsFeedToolbarHooks.php
Same filename and directory in other branches
Namespace
Drupal\announcements_feed\HookFile
-
core/
modules/ announcements_feed/ src/ Hook/ AnnouncementsFeedToolbarHooks.php
View source
<?php
namespace Drupal\announcements_feed\Hook;
use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\Render\ElementInfoManagerInterface;
use Drupal\Core\Session\AccountProxyInterface;
/**
* Toolbar hook implementations for announcements_feed.
*/
class AnnouncementsFeedToolbarHooks {
public function __construct(protected readonly ElementInfoManagerInterface $elementInfoManager, protected readonly AccountProxyInterface $account) {
}
/**
* Implements hook_toolbar_alter().
*/
public function toolbarAlter(&$items) : void {
// 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;
}
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| AnnouncementsFeedToolbarHooks | Toolbar hook implementations for announcements_feed. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.