/**
  * Displays contact form and sends e-mail message when using POST request.
  *
  * @param \eZ\Publish\Core\MVC\Symfony\View\View $view
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \eZ\Publish\Core\MVC\Symfony\View\View|\Symfony\Component\HttpFoundation\Response
  */
 public function showContactFormAction(View $view, Request $request)
 {
     $form = $this->form->getForm();
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             // sends e-mail using submitted data
             $sendingStatus = $this->sender->send($form->getData(), $this->emailTitle, $this->senderEmail, $this->recipientEmail);
             if ($sendingStatus) {
                 // redirects user to confirmation page after successful sending of e-mail
                 return new RedirectResponse($this->router->generate('app.submitted'));
             }
         }
     }
     $view->addParameters(['form' => $form->createView()]);
     return $view;
 }
 /**
  * Displays contact form and sends e-mail message when using POST request.
  *
  * @param \eZ\Publish\Core\MVC\Symfony\View\View $view
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \eZ\Publish\Core\MVC\Symfony\View\View|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function showContactFormAction(View $view, Request $request)
 {
     $form = $this->formFactory->create(ContactType::class);
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $contact = $form->getData();
             try {
                 $this->sender->send($contact);
                 // redirects user to confirmation page after successful sending of e-mail
                 return new RedirectResponse($this->router->generate('app.submitted'));
             } catch (\Exception $e) {
                 //Todo add flash message to notify the user
             }
         }
     }
     $view->addParameters(['form' => $form->createView()]);
     return $view;
 }