You are here

public function MongodbShortcutSetStorage::getDefaultSet in MongoDB 8

Gets the default shortcut set for a given user account.

Parameters

\Drupal\Core\Session\AccountInterface $account: The user account whose default shortcut set will be returned.

Return value

\Drupal\shortcut\ShortcutSetInterface An object representing the default shortcut set.

Overrides ShortcutSetStorageInterface::getDefaultSet

File

mongodb_shortcut/src/MongodbShortcutSetStorage.php, line 121
Contains \Drupal\mongodb_shortcut\MongodbShortcutSetStorage.

Class

MongodbShortcutSetStorage

Namespace

Drupal\mongodb_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', array(
    $account,
  )));
  $suggestions[] = 'default';
  $shortcut_set = NULL;
  foreach ($suggestions as $name) {
    if ($shortcut_set = $this
      ->load($name)) {
      break;
    }
  }
  return $shortcut_set;
}