function shortcut_current_displayed_set
Same name and namespace in other branches
- 7.x modules/shortcut/shortcut.module \shortcut_current_displayed_set()
- 9 core/modules/shortcut/shortcut.module \shortcut_current_displayed_set()
- 8.9.x core/modules/shortcut/shortcut.module \shortcut_current_displayed_set()
Returns the current displayed shortcut set for the provided user account.
Parameters
$account: (optional) The user account whose shortcuts will be returned. Defaults to the currently logged-in user.
Return value
\Drupal\shortcut\ShortcutSetInterface An object representing the shortcut set that should be displayed to the current user. If the user does not have an explicit shortcut set defined, the default set is returned.
Deprecated
in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\shortcut\ShortcutSetStorageInterface::getDisplayedToUser() instead.
See also
https://www.drupal.org/node/3427050
1 string reference to 'shortcut_current_displayed_set'
- drupal_static_reset in core/
includes/ bootstrap.inc - Resets one or all centrally stored static variable(s).
File
-
core/
modules/ shortcut/ shortcut.module, line 142
Code
function shortcut_current_displayed_set($account = NULL) {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \\Drupal\\shortcut\\ShortcutSetStorageInterface::getDisplayedToUser() instead. See https://www.drupal.org/node/3427050', E_USER_DEPRECATED);
$shortcut_sets =& drupal_static(__FUNCTION__, []);
$user = \Drupal::currentUser();
if (!isset($account)) {
$account = $user;
}
// Try to return a shortcut set from the static cache.
if (isset($shortcut_sets[$account->id()])) {
return $shortcut_sets[$account->id()];
}
// If none was found, try to find a shortcut set that is explicitly assigned
// to this user.
$shortcut_set = \Drupal::entityTypeManager()->getStorage('shortcut_set')
->getDisplayedToUser($account);
$shortcut_sets[$account->id()] = $shortcut_set;
return $shortcut_set;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.