function shortcut_current_displayed_set in Zircon Profile 8.0
Same name and namespace in other branches
- 8 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.
12 calls to shortcut_current_displayed_set()
- MigrateShortcutSetUsersTest::testShortcutSetUsersMigration in core/
modules/ shortcut/ src/ Tests/ Migrate/ d7/ MigrateShortcutSetUsersTest.php - Test the shortcut set migration.
- ShortcutsBlock::build in core/
modules/ shortcut/ src/ Plugin/ Block/ ShortcutsBlock.php - Builds and returns the renderable array for this block plugin.
- ShortcutSetsTest::testShortcutSetAssign in core/
modules/ shortcut/ src/ Tests/ ShortcutSetsTest.php - Tests switching another user's shortcut set.
- ShortcutSetsTest::testShortcutSetSwitchCreate in core/
modules/ shortcut/ src/ Tests/ ShortcutSetsTest.php - Tests switching a user's shortcut set and creating one at the same time.
- ShortcutSetsTest::testShortcutSetSwitchNoSetName in core/
modules/ shortcut/ src/ Tests/ ShortcutSetsTest.php - Tests switching a user's shortcut set without providing a new set name.
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 164 - Allows users to manage customizable lists of shortcut links.
Code
function shortcut_current_displayed_set($account = NULL) {
$shortcut_sets =& drupal_static(__FUNCTION__, array());
$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::entityManager()
->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;
}