protected function UserStorage::doSaveFieldItems in Drupal 8
Same name and namespace in other branches
- 9 core/modules/user/src/UserStorage.php \Drupal\user\UserStorage::doSaveFieldItems()
- 10 core/modules/user/src/UserStorage.php \Drupal\user\UserStorage::doSaveFieldItems()
Writes entity field values to the storage.
This method is responsible for allocating entity and revision identifiers and updating the entity object with their values.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity object.
string[] $names: (optional) The name of the fields to be written to the storage. If an empty value is passed all field values are saved.
Overrides SqlContentEntityStorage::doSaveFieldItems
File
- core/
modules/ user/ src/ UserStorage.php, line 20
Class
- UserStorage
- Controller class for users.
Namespace
Drupal\userCode
protected function doSaveFieldItems(ContentEntityInterface $entity, array $names = []) {
// The anonymous user account is saved with the fixed user ID of 0.
// Therefore we need to check for NULL explicitly.
if ($entity
->id() === NULL) {
$entity->uid->value = $this->database
->nextId($this->database
->query('SELECT MAX(uid) FROM {' . $this
->getBaseTable() . '}')
->fetchField());
$entity
->enforceIsNew();
}
return parent::doSaveFieldItems($entity, $names);
}