function ShortcutSetStorage::assignUser
Assigns a user to a particular shortcut set.
Parameters
\Drupal\shortcut\ShortcutSetInterface $shortcut_set: An object representing the shortcut set.
$account: A user account that will be assigned to use the set.
Overrides ShortcutSetStorageInterface::assignUser
File
- 
              core/modules/ shortcut/ src/ ShortcutSetStorage.php, line 91 
Class
- ShortcutSetStorage
- Defines a storage for shortcut_set entities.
Namespace
Drupal\shortcutCode
public function assignUser(ShortcutSetInterface $shortcut_set, $account) {
  $current_shortcut_set = $this->getDisplayedToUser($account);
  $this->connection
    ->merge('shortcut_set_users')
    ->key('uid', $account->id())
    ->fields([
    'set_name' => $shortcut_set->id(),
  ])
    ->execute();
  if ($current_shortcut_set instanceof ShortcutSetInterface) {
    Cache::invalidateTags($current_shortcut_set->getCacheTagsToInvalidate());
  }
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
