public function ShortcutLazyBuilders::lazyLinks in Drupal 10
Same name and namespace in other branches
- 8 core/modules/shortcut/src/ShortcutLazyBuilders.php \Drupal\shortcut\ShortcutLazyBuilders::lazyLinks()
- 9 core/modules/shortcut/src/ShortcutLazyBuilders.php \Drupal\shortcut\ShortcutLazyBuilders::lazyLinks()
#lazy_builder callback; builds shortcut toolbar links.
Return value
array A renderable array of shortcut links.
File
- core/
modules/ shortcut/ src/ ShortcutLazyBuilders.php, line 44
Class
- ShortcutLazyBuilders
- Lazy builders for the shortcut module.
Namespace
Drupal\shortcutCode
public function lazyLinks() {
$shortcut_set = shortcut_current_displayed_set();
$links = shortcut_renderable_links();
$configure_link = NULL;
if (shortcut_set_edit_access($shortcut_set)
->isAllowed()) {
$configure_link = [
'#type' => 'link',
'#title' => t('Edit shortcuts'),
'#url' => Url::fromRoute('entity.shortcut_set.customize_form', [
'shortcut_set' => $shortcut_set
->id(),
]),
'#options' => [
'attributes' => [
'class' => [
'edit-shortcuts',
],
],
],
];
}
$build = [
'shortcuts' => $links,
'configure' => $configure_link,
];
$this->renderer
->addCacheableDependency($build, $shortcut_set);
return $build;
}