Example #1
0
 /**
  * Personal data form onSuccess event handler
  * @param PersonalUserForm $form
  */
 public function userFormSuccess(PersonalUserForm $form)
 {
     $values = $form->getValues();
     try {
         $this->userService->updateUser(UserEntityManageHelper::hydrateUserFromHash($values));
     } catch (Exceptions\DuplicateEntryException $ex) {
         switch ($ex->getCode()) {
             case Exceptions\DuplicateEntryException::EMAIL_EXISTS:
                 $form['email']->addError("User with specified email '{$values->email}' already exists");
                 break;
             case Exceptions\DuplicateEntryException::BIRTH_NUM_EXISTS:
                 $form['birthNumber']->addError("User with specified birth number '{$values->birthNumber}' already exists");
                 break;
         }
     } catch (Exceptions\DataErrorException $ex) {
         $this->handleDataSave($values->id, "default", $ex);
     }
 }
Example #2
0
 /**
  * Update user handler (topdown)
  * @param \Nette\ArrayHash $values
  */
 public function updateUser(ArrayHash $values)
 {
     try {
         $this->userService->updateUser(UserEntityManageHelper::hydrateUserFromHash($values));
     } catch (Exceptions\DataErrorException $ex) {
         $this->logError($ex->getMessage());
         $m = $this->tt("usersModule.messages.updateUserFailed", ["id" => $values->id]);
         $this->flashMessage($m, self::FM_ERROR);
     }
     $this->redirect("Admin:default");
 }