コード例 #1
0
 public function testGivenThatWePreviouslyAttachedTheXReadingGroupHeaderToTheyWillBeAPartOfTheReturnedArray()
 {
     $this->request->headers->set(HeaderKey::REQUEST_ADDITION, HeaderKey::REQUEST_ADDITION_VALUE);
     $expectedReturn = [HeaderKey::REQUEST_ADDITION => HeaderKey::REQUEST_ADDITION_VALUE, 'product' => ['id' => 312, 'name' => 'A product name']];
     $actualReturn = $this->controller->getProductAction($this->request);
     $this->assertEquals($expectedReturn, $actualReturn, 'Expected the controller to return an array with the header.');
 }
コード例 #2
0
ファイル: PageController.php プロジェクト: benblub/sym
 /**
  * @Route("/demo/contact", name="contact_form")
  */
 public function contactAction(Request $request)
 {
     // create a task and give it some dummy data for this example
     $task = new Task();
     $form = $this->createFormBuilder($task)->add('name', 'text')->add('email', 'text')->add('text', 'textarea', array('attr' => array('cols' => '5', 'rows' => '5')))->add('save', 'submit', array('label' => 'senden'))->getForm();
     $form->handleRequest($request);
     if ($form->isValid()) {
         // Google Recaptcha 2
         $googleCaptcha = $request->request->get('g-recaptcha-response');
         $google = new ApiController();
         $googleResponse = $google->googleRecaptchaAction($googleCaptcha);
         echo '<pre>';
         print_r($googleResponse);
         exit;
         // if gResponse false return to contact twig add var gResponse->Failed
         // perform some action, such as saving the task to the database
         $message = \Swift_Message::newInstance()->setSubject('sf2 mail')->setFrom('*****@*****.**')->setTo('*****@*****.**')->setBody($request);
         $this->get('mailer')->send($message);
         return $this->redirectToRoute('task_success');
     }
     return $this->render('demo/contact.html.twig', array('form' => $form->createView()));
 }