Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. <?php
  2.  
  3. class Foo
  4. {
  5.  
  6.     public function detailsAction(Request $request, $quoteId)
  7.     {
  8.         $service = $this->get('surely_platform_api.platform_api_service');
  9.  
  10.         $form = $this->createForm(new PersonalDetailsType());
  11.         $form->handleRequest($request);
  12.  
  13.         if ($form->isValid()) {
  14.             $formData = $form->getData();
  15.  
  16.             $emailAddress = $formData['email'];
  17.             $personalId = $formData['person_id'];
  18.             $phoneNumber = $formData['mobile'];
  19.  
  20.             $apiResult = $service->createPolicyForQuote($quoteId, $emailAddress, $personalId, $phoneNumber);
  21.  
  22.             if (false == $apiResult->hasErrors) {
  23.                 $policyId = $apiResult->result;
  24.  
  25.                 return $this->redirect($this->generateUrl('dental_agree', array('policyId' => $policyId)));
  26.             }
  27.  
  28.             // Do something
  29.             foreach ($apiResult->errors as $error) {
  30.                 $form->addError(new FormError($error->Message));
  31.             }
  32.         }
  33.  
  34.         $apiResult = $service->getQuoteDetails($quoteId);
  35.         // TODO: Handle $apiResult->hasErrors
  36.         $quotePlan = $apiResult->result;
  37.  
  38.         return array('form' => $form->createView(), 'quote' => $quotePlan);
  39.     }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement