function ShortcutSetStorage::getDefaultSet

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

Overrides ShortcutSetStorageInterface::getDefaultSet

File

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

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.