public function ToolbarLinkBuilder::renderToolbarLinks in Drupal 8
Same name and namespace in other branches
- 9 core/modules/user/src/ToolbarLinkBuilder.php \Drupal\user\ToolbarLinkBuilder::renderToolbarLinks()
- 10 core/modules/user/src/ToolbarLinkBuilder.php \Drupal\user\ToolbarLinkBuilder::renderToolbarLinks()
Lazy builder callback for rendering toolbar links.
Return value
array A renderable array as expected by the renderer service.
File
- core/
modules/ user/ src/ ToolbarLinkBuilder.php, line 40
Class
- ToolbarLinkBuilder
- ToolbarLinkBuilder fills out the placeholders generated in user_toolbar().
Namespace
Drupal\userCode
public function renderToolbarLinks() {
$links = [
'account' => [
'title' => $this
->t('View profile'),
'url' => Url::fromRoute('user.page'),
'attributes' => [
'title' => $this
->t('User account'),
],
],
'account_edit' => [
'title' => $this
->t('Edit profile'),
'url' => Url::fromRoute('entity.user.edit_form', [
'user' => $this->account
->id(),
]),
'attributes' => [
'title' => $this
->t('Edit user account'),
],
],
'logout' => [
'title' => $this
->t('Log out'),
'url' => Url::fromRoute('user.logout'),
],
];
$build = [
'#theme' => 'links__toolbar_user',
'#links' => $links,
'#attributes' => [
'class' => [
'toolbar-menu',
],
],
'#cache' => [
'contexts' => [
'user',
],
],
];
return $build;
}