function UserLazyBuilder::userOperationLinks
Same name in other branches
- 10 core/modules/navigation/src/UserLazyBuilder.php \Drupal\navigation\UserLazyBuilder::userOperationLinks()
Returns the user operation links in navigation expected format.
Parameters
bool $include_edit: (Optional) Whether to include the edit account link or not.
Return value
array List of operation links for the current user.
1 call to UserLazyBuilder::userOperationLinks()
- UserLazyBuilder::renderNavigationLinks in core/
modules/ navigation/ src/ UserLazyBuilder.php - Lazy builder callback for rendering navigation links.
File
-
core/
modules/ navigation/ src/ UserLazyBuilder.php, line 60
Class
- UserLazyBuilder
- User navigation block lazy builder.
Namespace
Drupal\navigationCode
public function userOperationLinks(bool $include_edit = TRUE) : array {
$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'),
],
];
if (!$include_edit) {
unset($links['account_edit']);
}
return $links;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.