function shortcut_default_set

Same name in other branches
  1. 7.x modules/shortcut/shortcut.module \shortcut_default_set()
  2. 8.9.x core/modules/shortcut/shortcut.module \shortcut_default_set()
  3. 10 core/modules/shortcut/shortcut.module \shortcut_default_set()

Returns the default shortcut set for a given user account.

Parameters

object $account: (optional) The user account whose default shortcut set will be returned. If not provided, the function will return the currently logged-in user's default shortcut set.

Return value

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

4 calls to shortcut_default_set()
ShortcutSet::postSave in core/modules/shortcut/src/Entity/ShortcutSet.php
Acts on a saved entity before the insert or update hook is invoked.
ShortcutSetsTest::testShortcutSetUnassign in core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php
Tests unassigning a shortcut set.
ShortcutSetsTest::testShortcutSetUnassignOnUserRemoval in core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php
Tests assign clearing on user removal.
shortcut_current_displayed_set in core/modules/shortcut/shortcut.module
Returns the current displayed shortcut set for the provided user account.
1 string reference to 'shortcut_default_set'
ShortcutSetDeleteForm::buildForm in core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php
Form constructor.

File

core/modules/shortcut/shortcut.module, line 169

Code

function shortcut_default_set($account = NULL) {
    $user = \Drupal::currentUser();
    if (!isset($account)) {
        $account = $user;
    }
    // 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(\Drupal::moduleHandler()->invokeAll('shortcut_default_set', [
        $account,
    ]));
    $suggestions[] = 'default';
    foreach ($suggestions as $name) {
        if ($shortcut_set = ShortcutSet::load($name)) {
            break;
        }
    }
    return $shortcut_set;
}

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