60 lines
1.9 KiB
PHP
60 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace KupShop\ContentBundle\Controller;
|
|
|
|
use KupShop\ContentBundle\View\ContactFormView;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
|
class ContactFormController extends AbstractController
|
|
{
|
|
/**
|
|
* @Route(path="/formulare/{type}/", defaults={"type"="kontakt", "old"=false})
|
|
*
|
|
* @return \Symfony\Component\HttpFoundation\Response
|
|
*/
|
|
public function SendFormAction(Request $request, ContactFormView $view, $type, $old = false)
|
|
{
|
|
if (findModule(\Modules::COMPONENTS)) {
|
|
throw new NotFoundHttpException();
|
|
}
|
|
$view->setRequest($request);
|
|
$view->setFormType($type);
|
|
$view->setCompatibilityMode($old);
|
|
|
|
$view->setFormData(array_merge($request->query->all(), $request->request->all()));
|
|
|
|
if ($request->isMethod('POST')) {
|
|
if ($view->submitForm()) {
|
|
return new RedirectResponse(
|
|
path('kupshop_content_contactform_sendform_sent', ['type' => $type])
|
|
);
|
|
}
|
|
}
|
|
|
|
return $view->getResponse();
|
|
}
|
|
|
|
/**
|
|
* @Route(path="/formulare/{type}/odeslano", defaults={"type"="kontakt"}, name="kupshop_content_contactform_sendform_sent")
|
|
*
|
|
* @return \Symfony\Component\HttpFoundation\Response
|
|
*/
|
|
public function SentAction(Request $request, ContactFormView $view, $type)
|
|
{
|
|
if (findModule(\Modules::COMPONENTS)) {
|
|
throw new NotFoundHttpException();
|
|
}
|
|
$view->setRequest($request);
|
|
$view->setFormType($type);
|
|
$view->setEmailSent(true);
|
|
|
|
$view->setFormData(array_merge($request->query->all(), $request->request->all()));
|
|
|
|
return $view->getResponse();
|
|
}
|
|
}
|