/**
  * @param UI\Form $form
  *
  * @throws \Aprila\DuplicateEntryException
  */
 public function userFormSucceeded(UI\Form $form)
 {
     try {
         $values = $form->getValues();
         // if we not use images
         if (!isset($values->avatar)) {
             $values['avatar'] = NULL;
         }
         if (isset($values->id) && $values->id > 0) {
             $this->canUser('edit');
             // edit
             $this->userManager->edit($values->id, $values);
             $this->flashMessage('User was updated');
             $this->redirect('edit', $values->id);
         } else {
             $this->canUser('add');
             // add
             $person = $this->userManager->add($values);
             $this->flashMessage('User was added');
             $this->redirect('edit', $person->id);
         }
     } catch (DuplicateEntryException $e) {
         $form->addError('Duplicate username or email.');
     }
 }
 /**
  * @param UI\Form $form
  */
 public function userFormSucceeded(UI\Form $form)
 {
     $values = $form->getValues();
     // if we not use images
     if (!isset($values->avatar)) {
         $values['avatar'] = NULL;
     }
     $person = $this->userManager->edit($this->user->id, ['name' => $values->name, 'avatar' => $values->avatar]);
     $this->person = $person;
     // update identity
     $this->user->identity->name = $person->name;
     $this->user->identity->avatar = $person->avatar;
     $this->flashMessage('Profile was updated');
     $this->redirect('default');
 }
 /**
  * @param UI\Form $form
  */
 public function userFormSucceeded(UI\Form $form, ArrayHash $values)
 {
     $data = ['name' => $values->name];
     if ($this->mainManager->isImage()) {
         $image = $this->saveImage($values->avatar);
         if ($image) {
             $data['avatar_namespace'] = $image['namespace'];
             $data['avatar_filename'] = $image['filename'];
         }
     }
     $this->detailObject = $this->mainManager->edit($this->user->id, $data);
     $person = $this->detailObject;
     // update identity
     $this->user->identity->name = $person->name;
     $this->user->identity->avatar_namespace = $person->avatar_namespace;
     $this->user->identity->avatar_filename = $person->avatar_filename;
     $this->flashMessage('Profile was updated');
     $this->redirect('default');
 }