/**
  * Handle the command
  *
  * @param UserEditCommand $command
  * @return mixed
  */
 public function handle($command)
 {
     $user = $command->user;
     $changes = [];
     if ($command->emailWasChanged()) {
         $user->setEmail($command->email);
         $changes['email'] = 'Changed';
     }
     if ($command->passwordWasChanged()) {
         $changes['password'] = '******';
         $user->setPassword($command->password);
     }
     foreach ($command->extraFields as $field => $value) {
         if ($command->extraFieldWasChanged($field)) {
             $user->setExtra($field, $value);
         }
     }
     if (!$this->userRepository->save($user)) {
         throw new UserNotStoredException($user);
     }
     return $changes;
 }
Exemple #2
0
 /**
  * @param UserEditCommand $command
  * @return bool
  */
 protected function passwordChangeFailed(UserEditCommand $command)
 {
     return $command->passwordWasChanged() && !$command->passwordMatches();
 }