示例#1
0
 public function formSucceeded(Form $form)
 {
     try {
         $p = $this->getPresenter();
         $values = $form->getValues();
         $tag = $this->getSelectedTag($form);
         if ($this->item) {
             $ent = $this->articleRepository->update($values, $tag, $this->user, $this->item);
             $p->flashMessage($this->translator->translate('locale.item.updated'));
         } else {
             $ent = $this->articleRepository->create($values, $tag, $this->user, new Entities\ArticleEntity());
             $p->flashMessage($this->translator->translate('locale.item.created'));
         }
     } catch (Exceptions\MissingTagException $e) {
         $this->addFormError($form, $e);
     } catch (PossibleUniqueKeyDuplicationException $e) {
         $this->addFormError($form, $e);
     } catch (\Exception $e) {
         $this->addFormError($form, $e, $this->translator->translate('locale.error.occurred'));
     }
     if (!empty($ent)) {
         $p->redirect('this');
     }
 }