Exemple #1
0
 /**
  * @param array $data
  * @return ContactEntity|TRUE
  */
 public function register(array $data)
 {
     $contactEntity = new ContactEntity();
     $userEntity = new UserEntity();
     $contactEntity->setValues($data);
     $userEntity->setLogin($data['login']);
     $userEntity->setAclRoleID(10);
     // guest role
     $userEntity->setPassword($data['password']);
     $userEntity->setActive(TRUE);
     if (isset($data['lastLogged'])) {
         $userEntity->setLastLogged($data['lastLogged']);
     }
     if (isset($data['ip'])) {
         $userEntity->setIp($data['ip']);
     }
     $contactEntity->setUser($userEntity);
     $this->contactRepository->push($contactEntity);
     $result = $this->contactRepository->save();
     if ($result) {
         return $this->contactRepository->get($this->contactRepository->getLastInsertID());
     } else {
         return $result;
     }
 }
Exemple #2
0
 /** Submit
  * @param Form $form
  */
 public function Submit(Form $form)
 {
     $values = $form->getValues();
     $contactEntity = new ContactEntity();
     $userEntity = new UserEntity();
     $contactEntity->setValues((array) $values);
     $userEntity->setLogin($values->login);
     $userEntity->setAclRoleID(10);
     // guest role
     $userEntity->setPassword($values->password);
     $userEntity->setActive(TRUE);
     $contactEntity->setUser($userEntity);
     try {
         $this->contactRepository->push($contactEntity);
         $result = $this->contactRepository->save();
         if ($result) {
             $this->flashMessage("Vaše registrace proběhla úspěšně.");
             $this->redirect('this');
         } else {
             $form->addError("Vaše registrace neproběhla úspěšně.");
         }
     } catch (\PDOException $e) {
         if (strpos($e->getMessage(), "1062 Duplicate entry") !== FALSE) {
             $form->addError("Uživatel {$values->login} již existuje. Zvolte si prosím jiný přihlašovací email.");
         } else {
             $form->addError($e->getMessage());
         }
     }
 }