src/Controller/ContactController.php line 33

Open in your IDE?
  1. <?php
  2. /**
  3. * Form Controller
  4. *
  5. * @author Vincent van Waasbergen <v.vanwaasbergen@visualmedia.nl>
  6. */
  7. namespace App\Controller;
  8. use App\Form\Type\ContactType;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use VisualMedia\LisaBundle\Controller\BaseController;
  12. use VisualMedia\PageBundle\Manager\BasePageManager;
  13. /**
  14. * Form Controller
  15. */
  16. class ContactController extends BaseController
  17. {
  18. /**
  19. * @param Request $request
  20. * @return Response
  21. */
  22. public function indexAction(Request $request): Response
  23. {
  24. $translator = $this->get('translator');
  25. $title = $translator->trans('contact.title', [], 'pages');
  26. $pageManager = $this->get(BasePageManager::class);
  27. $page = $pageManager->getOrCreatePage('contact', [
  28. 'title' => $title,
  29. 'published' => true,
  30. 'indexable' => true,
  31. 'metaDescription' => "{$title}.",
  32. 'htmlContent' => "{$title}.",
  33. ]);
  34. $form = $this->createForm(ContactType::class);
  35. $form->handleRequest($request);
  36. if ($form->isSubmitted() && $form->isValid()) {
  37. return $this->handleForm($form, [
  38. // 'key' => 'test',
  39. // 'email' => 'dev@dappr.nl',
  40. // 'contact' => 'Test test',
  41. // 'template_int' => 'Email/test_int.html.twig',
  42. // 'template_ext' => 'Email/test_ext.html.twig',
  43. ]);
  44. }
  45. return $this->render('Contact/index.html.twig', [
  46. 'browser_title' => $page->browserTitle,
  47. 'meta_description' => $page->metaDescription,
  48. 'meta_keywords' => $page->metaKeywords,
  49. 'indexable' => $page->indexable,
  50. 'page' => $page,
  51. 'form' => $form->createView(),
  52. ]);
  53. }
  54. }