diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig index 14cc99c..f0ba10b 100644 --- a/app/Resources/views/base.html.twig +++ b/app/Resources/views/base.html.twig @@ -49,6 +49,9 @@
{% if user is defined and user %}
diff --git a/app/Resources/views/contact/contact.html.twig b/app/Resources/views/contact/contact.html.twig
new file mode 100644
index 0000000..008458c
--- /dev/null
+++ b/app/Resources/views/contact/contact.html.twig
@@ -0,0 +1,11 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+ {{ form_start(form) }}
+ {{ form_row(form.email) }}
+ {{ form_row(form.text) }}
+
+
+ {{ form_end(form) }}
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/config/services.yml b/app/config/services.yml
index e1653e4..9a346b5 100644
--- a/app/config/services.yml
+++ b/app/config/services.yml
@@ -24,6 +24,10 @@ services:
class: AppBundle\Controller\FaqController
autowire: true
+ app.controller.contact_controller:
+ class: AppBundle\Controller\ContactController
+ autowire: true
+
app.facade.category_facade:
class: AppBundle\Facade\CategoryFacade
autowire: true
@@ -44,6 +48,10 @@ services:
class: AppBundle\Facade\QuestionFacade
autowire: true
+ app.facade.message_facade:
+ class: AppBundle\Facade\MessageFacade
+ autowire: true
+
app.repository.category_repository:
class: AppBundle\Repository\CategoryRepository
factory: ['@doctrine.orm.default_entity_manager', getRepository]
diff --git a/src/AppBundle/Controller/ContactController.php b/src/AppBundle/Controller/ContactController.php
new file mode 100644
index 0000000..6b0d3ae
--- /dev/null
+++ b/src/AppBundle/Controller/ContactController.php
@@ -0,0 +1,52 @@
+formFactory = $formFactory;
+ $this->messageFacade = $messageFacade;
+ }
+
+ /**
+ * @Route("/contact", name="contact")
+ * @Template("contact/contact.html.twig")
+ */
+ public function contactAction(Request $request)
+ {
+ $messageVO = new MessageVO();
+ $form = $this->formFactory->create(ContactFormType::class, $messageVO);
+
+ $form->handleRequest($request);
+ if ($form->isSubmitted() && $form->isValid()) {
+ $this->messageFacade->save($messageVO);
+ }
+
+ return [
+ "form" => $form->createView()
+ ];
+ }
+}
\ No newline at end of file
diff --git a/src/AppBundle/Entity/Message.php b/src/AppBundle/Entity/Message.php
new file mode 100644
index 0000000..cb85c62
--- /dev/null
+++ b/src/AppBundle/Entity/Message.php
@@ -0,0 +1,74 @@
+id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getEmail() : string
+ {
+ return $this->email;
+ }
+
+ /**
+ * @param string $email
+ */
+ public function setEmail(string $email)
+ {
+ $this->email = $email;
+ }
+
+ /**
+ * @return string
+ */
+ public function getText(): string
+ {
+ return $this->text;
+ }
+
+ /**
+ * @param string $text
+ */
+ public function setText(string $text)
+ {
+ $this->text = $text;
+ }
+}
\ No newline at end of file
diff --git a/src/AppBundle/Facade/MessageFacade.php b/src/AppBundle/Facade/MessageFacade.php
new file mode 100644
index 0000000..0a309e0
--- /dev/null
+++ b/src/AppBundle/Facade/MessageFacade.php
@@ -0,0 +1,35 @@
+entityManager = $entityManager;
+ }
+
+ /**
+ * @param MessageVO $messageVO
+ */
+ public function save(MessageVO $messageVO)
+ {
+ $message = new Message();
+
+ $message->setEmail($messageVO->getEmail());
+ $message->setText($messageVO->getText());
+
+ $this->entityManager->persist($message);
+ $this->entityManager->flush($message);
+ }
+}
\ No newline at end of file
diff --git a/src/AppBundle/FormType/ContactFormType.php b/src/AppBundle/FormType/ContactFormType.php
new file mode 100644
index 0000000..48f4aba
--- /dev/null
+++ b/src/AppBundle/FormType/ContactFormType.php
@@ -0,0 +1,33 @@
+add("email", EmailType::class, [
+ "label" => "E-mail",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ "constraints" => [
+ new NotBlank(["message" => "Prosím vyplňte Váš e-mail"]),
+ ],
+ ])->add("text", TextareaType::class, [
+ "label" => "Zpráva",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ "constraints" => [
+ new NotBlank(["message" => "Prosím napište text zprávy"]),
+ ],
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/src/AppBundle/FormType/VO/MessageVO.php b/src/AppBundle/FormType/VO/MessageVO.php
new file mode 100644
index 0000000..b30bd64
--- /dev/null
+++ b/src/AppBundle/FormType/VO/MessageVO.php
@@ -0,0 +1,44 @@
+email;
+ }
+
+ /**
+ * @param string $email
+ */
+ public function setEmail(string $email)
+ {
+ $this->email = $email;
+ }
+
+ /**
+ * @return string
+ */
+ public function getText()
+ {
+ return $this->text;
+ }
+
+ /**
+ * @param string $text
+ */
+ public function setText(string $text)
+ {
+ $this->text = $text;
+ }
+}
\ No newline at end of file