You are here

public function MongodbShortcutSetStorage::assignUser in MongoDB 8

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

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

Class

MongodbShortcutSetStorage

Namespace

Drupal\mongodb_shortcut

Code

public function assignUser(ShortcutSetInterface $shortcut_set, $account) {
  $newobj = [
    '_id' => $account
      ->id(),
    'set_name' => $shortcut_set
      ->id(),
  ];
  $this->mongo
    ->get('shortcut_set_users')
    ->update([
    '_id' => $account
      ->id(),
  ], $newobj, [
    'upsert' => TRUE,
  ]);
  drupal_static_reset('shortcut_current_displayed_set');
}