Update user informations

@param array                  $data
@param \PlaygroundUser\Entity\UserInterface $user
508318
public function updateInfo(array $data, $user)
    {
        $this->getEventManager()->trigger(__FUNCTION__.'.pre', $this, array('user' => $user, 'data' => $data));

        $form  = $this->getServiceManager()->get('playgrounduser_change_info_form');
        $form->get('dob')->setOptions(array('format' => 'Y-m-d'));
        $form->bind($user);

        $data['id'] = $user->getId();
        $avatarPath = $this->getOptions()->getAvatarPath() . DIRECTORY_SEPARATOR;
        if (!is_dir($avatarPath)) {
            mkdir($avatarPath, 0777, true);
        }
        $avatarUrl = $this->getOptions()->getAvatarUrl() . '/';

        // If avatar is set, I prepend the url path to the image
        $fileName = null;
        if (isset($data['avatar'])) {
            $fileName = $data['avatar'];
            $data['avatar'] = $avatarUrl . $fileName;
        }

        if (!isset($data['username']) || $data['username'] == '') {
            if(isset($data['firstname']) && isset($data['lastname'])) {
                $data['username'] = ucfirst($data['firstname']) . " " . substr(ucfirst($data['lastname']), 0, 1);
            }
        }

        // Convert birth date format
        if (isset($data['dob']) && $data['dob']) {
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['dob']);
            $data['dob'] = $tmpDate->format('Y-m-d');
        }

        $form->setData($data);

        $filter = $user->getInputFilter();
        $filter->remove('password');
        $filter->remove('passwordVerify');
        $form->setInputFilter($filter);

        if (!$form->isValid()) {
            if (isset($data['dob']) && $data['dob']) {
                $tmpDate = \DateTime::createFromFormat('Y-m-d', $data['dob']);
                $data['dob'] = $tmpDate->format('d/m/Y');
                $form->setData(array('dob' => $data['dob']));
            }

            return false;
        }

        if ($fileName) {
            $adapter = new \Zend\File\Transfer\Adapter\Http();
            $size = new Size(array('max'=>'500kb'));
            $adapter->setValidators(array($size), $fileName);

            if (!$adapter->isValid()) {
                $dataError = $adapter->getMessages();
                if (isset($dataError['fileSizeTooBig'])) {
                    $dataError['fileSizeTooBig'] = 'Votre fichier dépasse le poids autorisé';
                }
                $error = array();
                foreach ($dataError as $key => $row) {
                    $error[] = $row;
                }
                if (isset($data['dob']) && $data['dob']) {
                    $tmpDate = \DateTime::createFromFormat('Y-m-d', $data['dob']);
                    $data['dob'] = $tmpDate->format('d/m/Y');
                    $form->setData(array('dob' => $data['dob']));
                }
                $form->setMessages(array('avatar'=>$error ));
            } else {
                $adapter->setDestination($avatarPath);
                if ($adapter->receive()) {
                    $user->setAvatar($avatarUrl . $adapter->getFileName(null, false));
                    $user = $this->getUserMapper()->update($user);
                    $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $user, 'data' => $data));

                    return $user;
                }
            }
        } else {
            $user = $this->getUserMapper()->update($user);
            $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $user, 'data' => $data));

            return $user;
        }

        return false;
    }
497870
protected function update(RecordInterface &$user)
    {
        // Load user from session
        $this->user = $user;
        $this->authorized = true;

        // Save to session
        $_SESSION[$this->identifier()] = serialize($this->user);

        // Tell all ancestors that we are in
        foreach (self::$ancestors as & $ancestor) {
            $ancestor->user = &$this->user;
            $ancestor->active = &$this;
            $ancestor->authorized = $this->authorized;
        }
    }
1214676
protected function updateUserFields(UserInterface $user)
    {
        if (null === $this->userDiscriminator) {
            $this->userDiscriminator = $this->container->get('rollerworks_multi_user.user_discriminator');
        }

        // Can only use the user manager when there is an user-system active
        if (null === $this->userDiscriminator->getCurrentUser() || true !== $this->userDiscriminator->getCurrentUserConfig()->getConfig('use_listener', true)) {
            return;
        }

        if (null === $this->userManager) {
            $this->userManager = $this->container->get('fos_user.user_manager');
        }

        $this->userManager->updateCanonicalFields($user);
        $this->userManager->updatePassword($user);
    }
1364910
protected function queueRecallerCookie(UserInterface $user)
    {
        $value = $user->getAuthIdentifier() .'|' .$user->getRememberToken();

        $cookie = $this->createRecaller($value);

        $this->getCookieJar()->queue($cookie);
    }
1005682
public function upgradeTemporaryUser(UserInterface $user, $values = [])
    {
        if (!$user->isTemporary()) {
            throw new AuthException('Cannot upgrade a non-temporary account');
        }

        $values = array_replace($values, [
            'created_at' => Utility::unixToDb(time()),
            'enabled' => true,
        ]);

        $user->grantAllPermissions();

        if (!$user->set($values)) {
            $user->enforcePermissions();

            throw new AuthException('Could not upgrade temporary account: '.implode($user->getErrors()->all()));
        }

        // remove temporary and unverified links
        $app = $user->getApp();
        $app['database']->getDefault()
            ->delete('UserLinks')
            ->where('user_id', $user->id())
            ->where(function ($query) {
                return $query->where('type', UserLink::TEMPORARY)
                    ->orWhere('type', UserLink::VERIFY_EMAIL);
            })
            ->execute();
        $user->clearTemporaryLink();

        // send the user a welcome message
        $user->sendEmail('welcome');

        $user->enforcePermissions();

        return $this;
    }
1356720
private function updateUserByOAuthUserResponse(UserInterface $user, UserResponseInterface $response): SyliusUserInterface
    {
        /** @var SyliusUserInterface $user */
        Assert::isInstanceOf($user, SyliusUserInterface::class);

        /** @var UserOAuthInterface $oauth */
        $oauth = $this->oauthFactory->createNew();
        $oauth->setIdentifier($response->getUsername());
        $oauth->setProvider($response->getResourceOwner()->getName());
        $oauth->setAccessToken($response->getAccessToken());
        $oauth->setRefreshToken($response->getRefreshToken());

        $user->addOAuthAccount($oauth);

        $this->userManager->persist($user);
        $this->userManager->flush();

        return $user;
    }
847613
public function saveCorrection(array $data, User $user)
    {
        $this->om->startFlushSuite();
        $existingCorrection = $this->correctionRepo->findOneBy(['uuid' => $data['id']]);
        $isNew = empty($existingCorrection);
        $correction = $this->serializer->get(Correction::class)->deserialize($data);
        $correction->setUser($user);
        $dropzone = $correction->getDrop()->getDropzone();

        if (!$isNew) {
            $correction->setLastEditionDate(new \DateTime());
        }
        $correction = $this->computeCorrectionScore($correction);
        $this->om->persist($correction);
        $this->om->endFlushSuite();

        if ($isNew) {
            $this->eventDispatcher->dispatch('log', new LogCorrectionStartEvent($dropzone, $correction->getDrop(), $correction));
        } else {
            $this->eventDispatcher->dispatch('log', new LogCorrectionUpdateEvent($dropzone, $correction->getDrop(), $correction));
        }

        return $correction;
    }
249397
protected function updateUserPorfile($data)
    {
        $data = $data->except('email');

        if ($data instanceof Collection) {
            $data = $data->toArray();
        }

        if (isset($data['password'])) {
            $data['password'] = Hash::make($data['password']);
        }

        Auth::user()->update($data);
    }
1049924
public function updateUser(User $user)
    {
        try {
            return $this->innerGateway->updateUser($user);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1244956
public function updateUser(User $user, UserUpdater $up)
    {
        $up->updateUser($user, $this->getEncoder());
        $em = $this->getRegistry()->getManager();
        $em->persist($user);
        $em->flush();
    }
658950
public function update(User $user, $flush = true)
    {
        $this->objectManager->persist($user);

        if ($flush) {
            $this->objectManager->flush();
        }
    }
851040
public function markAllAsRead(User $user)
    {
        Notification::where('user_id', $user->id)->update(['read_at' => Carbon::now()]);
    }
851861
public function setUserData(User $user)
    {
        $userVarArray = get_object_vars($user);

        foreach ($userVarArray as $key => $value) {
            if ($value !== null) {
                $this->{$key} = $value;
            }
        }
    }
1052277
public function doAuthentication(UserInterface $user)
    {
        /** @var \PServerCore\Entity\Repository\User $repository */
        $repository = $this->entityManager->getRepository($this->getUserEntityClassName());

        // fix if we have a proxy we don´t have a valid entity, so we have to clear before we can create a new select
        $username = $user->getUsername();
        $repository->clear();

        $userNew = $repository->getUser4UserName($username);

        $authService = $this->getAuthService();

        $authService->getStorage()->write($userNew);
    }
1153624
public function update(UserRequest $request, User $user)
    {
        $user->update($request->all());
        $this->_syncUserGroups($user, $request->get('user_group_id'));
        return redirect()->route('admin.user.index');
    }
421324
protected function setUser(array $userData, & $user = null)
    {
        // Generic birthdate parsing
        $user->birthday = date('Y-m-d H:i:s', strtotime($user->birthday));

        // If no external user is passed set as current user
        if (isset($user)) {
            $this->user = & $user;
        }
    }
145281
public function update(User $user, array $data)
    {
        $user->fill([
            'name'                  => $data['name'],
            'email'                 => $data['email'],
            'birthday_at'           => $data['birthday_at'],
            'gender'                => $data['gender'],
            'locale'                => $data['locale'],
            'city'                  => $data['city'],
            'about'                 => $data['about'],
            'profession'            => $data['profession'],
            'hobbies'               => $data['hobbies'],
            'homepage'              => $data['homepage'],
            'skype'                 => $data['skype'],
            'facebook'              => $data['facebook'],
            'twitter'               => $data['twitter'],
            'main_character'        => $data['main_character'],
            'main_guild'            => $data['main_guild'],
            'favorite_race'         => $data['favorite_race'],
            'favorite_class'        => $data['favorite_class'],
            'favorite_spec'         => $data['favorite_spec'],
            'favorite_instance'     => $data['favorite_instance'],
            'favorite_battleground' => $data['favorite_battleground'],
        ]);

        // only fill password if specified
        if (array_key_exists('password', $data)
            && !empty($data['password'])) {
            $user->fill([
                'password' => bcrypt($data['password']),
            ]);
        }

        return $user->save();
    }