You are here

public function MongodbUserData::set in MongoDB 8

Stores data for a user account.

Parameters

string $module: The name of the module the data is associated with.

integer $uid: The user account ID the data is associated with.

string $name: The name of the data key.

mixed $value: The value to store. Non-scalar values are serialized automatically.

Return value

void

Overrides UserDataInterface::set

File

mongodb_user/src/MongodbUserData.php, line 85
Contains \Drupal\mongodb_user\MongodbUserData.

Class

MongodbUserData

Namespace

Drupal\mongodb_user

Code

public function set($module, $uid, $name, $value) {
  $criteria = [
    'module' => $module,
    'uid' => $uid,
    'name' => $name,
  ];
  $this->mongo
    ->get('user_data')
    ->update($criteria, $criteria + [
    'value' => $value,
  ], [
    'upsert' => TRUE,
  ]);
}