function shortcut_current_displayed_set
Same name in other branches
- 7.x modules/shortcut/shortcut.module \shortcut_current_displayed_set()
- 9 core/modules/shortcut/shortcut.module \shortcut_current_displayed_set()
- 10 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
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.
13 calls to shortcut_current_displayed_set()
- MigrateShortcutSetUsersTest::testShortcutSetUsersMigration in core/
modules/ shortcut/ tests/ src/ Kernel/ Migrate/ d7/ MigrateShortcutSetUsersTest.php - Test the shortcut set migration.
- ShortcutLazyBuilders::lazyLinks in core/
modules/ shortcut/ src/ ShortcutLazyBuilders.php - #lazy_builder callback; builds shortcut toolbar links.
- ShortcutsBlock::build in core/
modules/ shortcut/ src/ Plugin/ Block/ ShortcutsBlock.php - ShortcutSetsTest::testShortcutSetAssign in core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutSetsTest.php - Tests switching another user's shortcut set.
- ShortcutSetsTest::testShortcutSetSwitchCreate in core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutSetsTest.php - Tests switching a user's shortcut set and creating one at the same time.
1 string reference to 'shortcut_current_displayed_set'
- ShortcutSetStorage::assignUser in core/
modules/ shortcut/ src/ ShortcutSetStorage.php - Assigns a user to a particular shortcut set.
File
-
core/
modules/ shortcut/ shortcut.module, line 169
Code
function shortcut_current_displayed_set($account = NULL) {
$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_name = \Drupal::entityTypeManager()->getStorage('shortcut_set')
->getAssignedToUser($account);
if ($shortcut_set_name) {
$shortcut_set = ShortcutSet::load($shortcut_set_name);
}
else {
$shortcut_set = shortcut_default_set($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.