public function UserData::set in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/src/UserData.php \Drupal\user\UserData::set()
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
- core/
modules/ user/ src/ UserData.php, line 85 - Contains \Drupal\user\UserData.
Class
- UserData
- Defines the user data service.
Namespace
Drupal\userCode
public function set($module, $uid, $name, $value) {
$serialized = 0;
if (!is_scalar($value)) {
$value = serialize($value);
$serialized = 1;
}
$this->connection
->merge('users_data')
->keys(array(
'uid' => $uid,
'module' => $module,
'name' => $name,
))
->fields(array(
'value' => $value,
'serialized' => $serialized,
))
->execute();
}