function ShortcutNavigationBlock::build
Same name and namespace in other branches
- 11.x core/modules/shortcut/src/Plugin/Block/ShortcutNavigationBlock.php \Drupal\shortcut\Plugin\Block\ShortcutNavigationBlock::build()
File
-
core/
modules/ shortcut/ src/ Plugin/ Block/ ShortcutNavigationBlock.php, line 53
Class
- ShortcutNavigationBlock
- Defines a shortcuts navigation block class.
Namespace
Drupal\shortcut\Plugin\BlockCode
public function build() : array {
if (!$this->moduleHandler
->moduleExists('navigation')) {
return [];
}
return [
'shortcuts' => [
// @phpstan-ignore-next-line
'#lazy_builder' => [
'navigation.shortcut_lazy_builder:lazyLinks',
[
$this->configuration['label'],
],
],
'#create_placeholder' => TRUE,
'#cache' => [
'keys' => [
'shortcut_set_navigation_links',
],
'contexts' => [
'user',
],
],
'#lazy_builder_preview' => [
[
'#theme' => 'navigation_menu',
'#menu_name' => 'shortcuts',
'#title' => $this->configuration['label'],
'#items' => [
[
'title' => $this->configuration['label'],
'class' => 'shortcuts',
'icon' => [
'icon_id' => 'shortcuts',
],
],
],
],
],
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.