/** * save method * * @param void * @return void */ private function save($form) { $message = null; if ($this->_request->isPost()) { # get params $data = $this->_request->getPost(); if ($form->isValid($data)) { # check for existing email $accountExist = $this->_em->getRepository('Custom_Entity_Account')->findBy(array('email' => (string) $data['email'])); if (count($accountExist) == 0) { # register account $account = new Custom_Entity_Account; $account->setNickname($data['nickname']); $account->setFirstname($data['firstname']); $account->setLastname($data['lastname']); $account->setEmail($data['email']); $account->setPassword($data['password'], $this->_registry->config->auth->hash); $account->setCreated_at(new DateTime()); $this->_em->persist($account); $this->_em->flush(); # send to login page $this->_helper->redirector('successful', 'register', 'auth'); } else { $alert = 'Registration Failed: Email already exists'; // move to view } } # populate form $form->populate($data); } return array('form' => $form, 'alert' => empty($alert) ? null : $alert ); }