Example #1
0
 public function registerAction()
 {
     $registerForm = new Register();
     //TODO: we are changeing this in refactor code.
     $view = new ViewModel();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $postDataArray = $request->getPost();
         $registerForm->setData($this->getRequest()->getPost()->toArray());
         if ($registerForm->isValid()) {
             //print_r($postDataArray);exit;
             $encoder = $this->getServiceLocator()->get('app.password_encoder');
             $passwordEncode = $encoder->encode($postDataArray['password']);
             $postDataArray['password'] = $passwordEncode;
             $accountRepository = $this->getRepository('Account');
             // Create account
             $accountObj = $accountRepository->createAccount($postDataArray);
             // Create user
             $userRepository = $this->getRepository('User');
             $userRepository->createUser($accountObj, $postDataArray);
             // $flashMessenger = $this->_helper->getHelper('FlashMessenger');
             //$flashMessenger->addMessage('We did something in the last request');
             echo "saved";
         }
     }
     //public and private key are reading from User config file
     //TODO: Move to some comman file.
     //Get Key based on Environment.
     //Generate Key for production using (admin@costrategix.com)
     $applicationEnv = getenv('APPLICATION_ENV');
     //$this->layout('layout/guest_cms');
     $view->setVariable('registerForm', $registerForm);
     return $view;
 }
Example #2
0
 /**
  * @return array
  */
 public function registerAction()
 {
     $form = new Register($this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'));
     $form->get('primary')->setValue($this->getAuthenticationService()->getIdentity()->getId());
     $status = null;
     // Step 3: Returned from PayPal
     if ($this->params()->fromRoute('payum_token')) {
         $status = $this->getDogService()->completePayment($this);
         $details = $status->getFirstModel();
         if ($details instanceof DetailsAggregateInterface) {
             $details = $details->getDetails();
             if ($details instanceof \Traversable) {
                 $details = iterator_to_array($details);
             }
         }
         $form->setData($details['dogData']);
         if ($status->isCaptured()) {
             $this->getDogService()->registerNewDog($details['dogData']);
             return $this->redirect()->toRoute('home');
         }
         // Step 2: Confirm dog information and redirect to PayPal
     } elseif ($dogData = $this->session->offsetGet('dogData')) {
         $this->session->offsetUnset('dogData');
         $request = $this->getRequest();
         if ($request->isPost() && $request->getPost('confirm') !== null) {
             $token = $this->getDogService()->preparePayment($dogData, $this->getAuthenticationService()->getIdentity());
             return $this->redirect()->toUrl($token->getTargetUrl());
         }
         $form->setData($dogData);
         // Step 1: Collect dog information
     } else {
         $request = $this->getRequest();
         if ($request->isPost()) {
             if ($request->getPost('cancel') !== null) {
                 return $this->redirect()->toRoute('home');
             }
             $form->setData($request->getPost());
             if ($form->isValid()) {
                 $dogData = $form->getData();
                 $dogData['breedName'] = $this->getDogService()->getBreed($dogData['breed'])->getName();
                 $this->session->offsetSet('dogData', $dogData);
                 $form = new Confirm();
             }
         }
     }
     // Remove payum token from form action url if necessary
     $form->setAttribute('action', $this->url()->fromRoute('dog/register'));
     return array('form' => $form, 'status' => $status, 'dogData' => $this->session->offsetGet('dogData'));
 }