function ShortcutSetStorage::getDefaultSet

Same name in other branches
  1. 9 core/modules/shortcut/src/ShortcutSetStorage.php \Drupal\shortcut\ShortcutSetStorage::getDefaultSet()
  2. 8.9.x core/modules/shortcut/src/ShortcutSetStorage.php \Drupal\shortcut\ShortcutSetStorage::getDefaultSet()
  3. 10 core/modules/shortcut/src/ShortcutSetStorage.php \Drupal\shortcut\ShortcutSetStorage::getDefaultSet()

Overrides ShortcutSetStorageInterface::getDefaultSet

1 call to ShortcutSetStorage::getDefaultSet()
ShortcutSetStorage::getDisplayedToUser in core/modules/shortcut/src/ShortcutSetStorage.php
Gets the shortcut set to be displayed for a given user account.

File

core/modules/shortcut/src/ShortcutSetStorage.php, line 151

Class

ShortcutSetStorage
Defines a storage for shortcut_set entities.

Namespace

Drupal\shortcut

Code

public function getDefaultSet(AccountInterface $account) {
    // Allow modules to return a default shortcut set name. Since we can only
    // have one, we allow the last module which returns a valid result to take
    // precedence. If no module returns a valid set, fall back on the site-wide
    // default, which is the lowest-numbered shortcut set.
    $suggestions = array_reverse($this->moduleHandler
        ->invokeAll('shortcut_default_set', [
        $account,
    ]));
    $suggestions[] = 'default';
    $shortcut_set = NULL;
    foreach ($suggestions as $name) {
        if ($shortcut_set = $this->load($name)) {
            break;
        }
    }
    return $shortcut_set;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.