<?php
/**
* Form Controller
*
* @author Vincent van Waasbergen <v.vanwaasbergen@visualmedia.nl>
*/
namespace App\Controller;
use App\Form\Type\ContactType;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use VisualMedia\LisaBundle\Controller\BaseController;
use VisualMedia\PageBundle\Manager\BasePageManager;
/**
* Form Controller
*/
class ContactController extends BaseController
{
/**
* @param Request $request
* @return Response
*/
public function indexAction(Request $request): Response
{
$translator = $this->get('translator');
$title = $translator->trans('contact.title', [], 'pages');
$pageManager = $this->get(BasePageManager::class);
$page = $pageManager->getOrCreatePage('contact', [
'title' => $title,
'published' => true,
'indexable' => true,
'metaDescription' => "{$title}.",
'htmlContent' => "{$title}.",
]);
$form = $this->createForm(ContactType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
return $this->handleForm($form, [
// 'key' => 'test',
// 'email' => 'dev@dappr.nl',
// 'contact' => 'Test test',
// 'template_int' => 'Email/test_int.html.twig',
// 'template_ext' => 'Email/test_ext.html.twig',
]);
}
return $this->render('Contact/index.html.twig', [
'browser_title' => $page->browserTitle,
'meta_description' => $page->metaDescription,
'meta_keywords' => $page->metaKeywords,
'indexable' => $page->indexable,
'page' => $page,
'form' => $form->createView(),
]);
}
}