ShortcutSetStorage::getDefaultSet

public ShortcutSetStorage::getDefaultSet(AccountInterface $account)

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

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

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

  return $shortcut_set;
}
doc_Drupal
2016-10-29 09:42:57
Comments
Leave a Comment

Please login to continue.