Exemplo n.º 1
0
 public function zajemceFormSucceeded($button)
 {
     $values = $button->getForm()->getValues(true);
     $id = (int) $this->getParameter('id');
     if ($id) {
         try {
             $new_user = $this->users->update($id, $values);
             if ($new_user) {
                 $this->flashMessage('Účet zájemce byl upraven.');
             }
         } catch (\PDOException $e) {
             if ($e->getCode() == 23000) {
                 $this->flashMessage('Zájemce s tímto aliasem už je zaregistrován, zvolte prosím jiný.');
             } else {
                 throw $e;
             }
         }
     } else {
         // registrace noveho zajemce
         try {
             $new_user = $this->users->register($values);
             if ($new_user) {
                 $this->flashMessage('Účet zájemce byl vytvořen. Nyní se může přihlásit.');
             }
         } catch (\PDOException $e) {
             if ($e->getCode() == 23000) {
                 $this->flashMessage('Zájemce s tímto aliasem už je zaregistrován, zvolte prosím jiný.');
             } else {
                 throw $e;
             }
         }
     }
     $this->redirect('zajemci');
 }