public function updateUser(UserInterface $user, $insertInDb = false) { if ($this->user) { $user->setPassword($this->user->getPassword()); $user->setId($this->user->get('id')); $this->updateCanonicalFields($user); } if ($user->has('id')) { $result = $this->pommModel->updateOne($user, ['salt', 'password', 'username_canonical', 'email_canonical']); } else { $this->updateCanonicalFields($user); $this->updatePassword($user); $this->pommModel->insertOne($user); $this->user = $user; } }
private function fromDocument(UserInterface $user, Document $document) { if (!$user instanceof User) { throw new \InvalidArgumentException('Invalid user object'); } $user->fromArray($document->getAll()); $user->setId($document->getId()); return $user; }