X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fuser%2Fsrc%2FUserStorage.php;fp=web%2Fcore%2Fmodules%2Fuser%2Fsrc%2FUserStorage.php;h=809f3e384b73ee51827eccd5b15e85d88babcd86;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/user/src/UserStorage.php b/web/core/modules/user/src/UserStorage.php new file mode 100644 index 000000000..809f3e384 --- /dev/null +++ b/web/core/modules/user/src/UserStorage.php @@ -0,0 +1,76 @@ +id() === NULL) { + $entity->uid->value = $this->database->nextId($this->database->query('SELECT MAX(uid) FROM {users}')->fetchField()); + $entity->enforceIsNew(); + } + return parent::doSaveFieldItems($entity, $names); + } + + /** + * {@inheritdoc} + */ + protected function isColumnSerial($table_name, $schema_name) { + // User storage does not use a serial column for the user id. + return $table_name == $this->revisionTable && $schema_name == $this->revisionKey; + } + + /** + * {@inheritdoc} + */ + public function updateLastLoginTimestamp(UserInterface $account) { + $this->database->update('users_field_data') + ->fields(['login' => $account->getLastLoginTime()]) + ->condition('uid', $account->id()) + ->execute(); + // Ensure that the entity cache is cleared. + $this->resetCache([$account->id()]); + } + + /** + * {@inheritdoc} + */ + public function updateLastAccessTimestamp(AccountInterface $account, $timestamp) { + $this->database->update('users_field_data') + ->fields([ + 'access' => $timestamp, + ]) + ->condition('uid', $account->id()) + ->execute(); + // Ensure that the entity cache is cleared. + $this->resetCache([$account->id()]); + } + + /** + * {@inheritdoc} + */ + public function deleteRoleReferences(array $rids) { + // Remove the role from all users. + $this->database->delete('user__roles') + ->condition('roles_target_id', $rids) + ->execute(); + + $this->resetCache(); + } + +}