diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig
index 4f5d87e..6ddef89 100644
--- a/app/Resources/views/base.html.twig
+++ b/app/Resources/views/base.html.twig
@@ -46,6 +46,12 @@
Domů
+
+ FAQ
+
+
+ Kontakt
+
{% if user is defined and user %}
@@ -72,6 +78,14 @@
+ {% if app.session.flashBag.has('success') %}
+
+ {% for msg in app.session.flashBag.get('success') %}
+ {{ msg }}
+ {% endfor %}
+
+ {% endif %}
+
{% block body %}
{% endblock %}
diff --git a/app/Resources/views/faq/faq.html.twig b/app/Resources/views/faq/faq.html.twig
new file mode 100644
index 0000000..e905227
--- /dev/null
+++ b/app/Resources/views/faq/faq.html.twig
@@ -0,0 +1,23 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+ FAQ
+
+ {% for item in faq %}
+
+
+
+
+ {{ item.answer }}
+
+
+
+ {% endfor %}
+
+{% endblock %}
diff --git a/app/Resources/views/message/add.html.twig b/app/Resources/views/message/add.html.twig
new file mode 100644
index 0000000..975e392
--- /dev/null
+++ b/app/Resources/views/message/add.html.twig
@@ -0,0 +1,6 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+ Kontakt
+ {{ form(form) }}
+{% endblock %}
\ No newline at end of file
diff --git a/app/config/services.yml b/app/config/services.yml
index 59f9fb4..3afacbe 100644
--- a/app/config/services.yml
+++ b/app/config/services.yml
@@ -20,6 +20,14 @@ services:
class: AppBundle\Controller\UserController
autowire: true
+ app.controller.faq_controller:
+ class: AppBundle\Controller\FaqController
+ autowire: true
+
+ app.controller.message_controller:
+ class: AppBundle\Controller\MessageController
+ autowire: true
+
app.facade.category_facade:
class: AppBundle\Facade\CategoryFacade
autowire: true
@@ -32,6 +40,10 @@ services:
class: AppBundle\Facade\UserFacade
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]
@@ -42,6 +54,16 @@ services:
factory: ['@doctrine.orm.default_entity_manager', getRepository]
arguments: ['AppBundle\Entity\Product']
+ app.repository.faq_repository:
+ class: AppBundle\Repository\FaqRepository
+ factory: ['@doctrine.orm.default_entity_manager', getRepository]
+ arguments: ['AppBundle\Entity\Faq']
+
+ app.repository.message_repository:
+ class: AppBundle\Repository\MessageRepository
+ factory: ['@doctrine.orm.default_entity_manager', getRepository]
+ arguments: ['AppBundle\Entity\Message']
+
encoder:
class: Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder
arguments:
diff --git a/src/AppBundle/Controller/FaqController.php b/src/AppBundle/Controller/FaqController.php
new file mode 100644
index 0000000..826b911
--- /dev/null
+++ b/src/AppBundle/Controller/FaqController.php
@@ -0,0 +1,36 @@
+
+ * @Route(service="app.controller.faq_controller")
+ */
+class FaqController
+{
+ /**
+ * @var FaqFacade
+ */
+ private $faqFacade;
+
+ public function __construct(FaqFacade $faqFacade)
+ {
+ $this->faqFacade = $faqFacade;
+ }
+
+ /**
+ * @Route("/faq", name="faq")
+ * @Template("faq/faq.html.twig")
+ */
+ public function faq()
+ {
+ return [
+ "faq" => $this->faqFacade->getAll()
+ ];
+ }
+
+}
diff --git a/src/AppBundle/Controller/MessageController.php b/src/AppBundle/Controller/MessageController.php
new file mode 100644
index 0000000..5be822b
--- /dev/null
+++ b/src/AppBundle/Controller/MessageController.php
@@ -0,0 +1,61 @@
+
+ * @Route(service="app.controller.message_controller")
+ */
+class MessageController
+{
+ private $messageFacade;
+ private $formFactory;
+ private $router;
+
+ public function __construct(
+ MessageFacade $messageFacade,
+ FormFactory $formFactory,
+ RouterInterface $router
+ ) {
+ $this->messageFacade = $messageFacade;
+ $this->formFactory = $formFactory;
+ $this->router = $router;
+ }
+
+ /**
+ * @Route("/kontakt", name="message_add")
+ * @Template("message/add.html.twig")
+ *
+ * @param Request $request
+ * @return RedirectResponse|array
+ */
+ public function addAction(Request $request)
+ {
+ $message = new Message();
+ $form = $this->formFactory->create(MessageFormType::class, $message);
+
+ $form->handleRequest($request);
+ if ($form->isSubmitted() && $form->isValid()) {
+
+ $this->messageFacade->saveMessage($message);
+
+ $request->getSession()->getFlashBag()->add('success', 'Vaša správa bola odoslaná');
+
+ return RedirectResponse::create($this->router->generate("homepage"));
+ }
+
+ return [
+ "form" => $form->createView(),
+ ];
+ }
+}
diff --git a/src/AppBundle/Entity/Faq.php b/src/AppBundle/Entity/Faq.php
new file mode 100644
index 0000000..476e8da
--- /dev/null
+++ b/src/AppBundle/Entity/Faq.php
@@ -0,0 +1,78 @@
+
+ *
+ * @ORM\Entity(repositoryClass="AppBundle\Repository\FaqRepository")
+ */
+class Faq
+{
+
+ /**
+ * @var int
+ * @ORM\Id
+ * @ORM\GeneratedValue
+ * @ORM\Column(type="integer")
+ */
+ private $id;
+
+ /**
+ * @var string
+ * @ORM\Column(type="string")
+ */
+ private $question;
+
+ /**
+ * @var string
+ * @ORM\Column(type="string")
+ */
+ private $answer;
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getQuestion()
+ {
+ return $this->question;
+ }
+
+ /**
+ * @param string $question
+ * @return self
+ */
+ public function setQuestion($question)
+ {
+ $this->question = $question;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getAnswer()
+ {
+ return $this->answer;
+ }
+
+ /**
+ * @param string $answer
+ * @return self
+ */
+ public function setAnswer($answer)
+ {
+ $this->answer = $answer;
+ return $this;
+ }
+}
\ 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..46f4f3a
--- /dev/null
+++ b/src/AppBundle/Entity/Message.php
@@ -0,0 +1,107 @@
+
+ *
+ * @ORM\Entity(repositoryClass="AppBundle\Repository\MessageRepository")
+ */
+class Message
+{
+
+ /**
+ * @var int
+ * @ORM\Id
+ * @ORM\GeneratedValue
+ * @ORM\Column(type="integer")
+ */
+ private $id;
+
+ /**
+ * @var string
+ * @ORM\Column(type="string")
+ * @Assert\NotBlank()
+ */
+ private $name;
+
+ /**
+ * @var string
+ * @ORM\Column(type="string")
+ * @Assert\NotBlank()
+ * @Assert\Email()
+ */
+ private $email;
+
+ /**
+ * @var string
+ * @ORM\Column(type="string")
+ * @Assert\NotBlank()
+ */
+ private $message;
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * @param string $email
+ * @return self
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getMessage()
+ {
+ return $this->message;
+ }
+
+ /**
+ * @param string $message
+ * @return self
+ */
+ public function setMessage($message)
+ {
+ $this->message = $message;
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/AppBundle/Facade/FaqFacade.php b/src/AppBundle/Facade/FaqFacade.php
new file mode 100644
index 0000000..8fcb2b3
--- /dev/null
+++ b/src/AppBundle/Facade/FaqFacade.php
@@ -0,0 +1,25 @@
+
+ */
+class FaqFacade {
+
+ /*
+ * @var FaqRepository
+ */
+ private $faqRepository;
+
+ public function __construct(FaqRepository $faqRepository) {
+ $this->faqRepository = $faqRepository;
+ }
+
+ public function getAll() {
+ return $this->faqRepository->findAll();
+ }
+}
diff --git a/src/AppBundle/Facade/MessageFacade.php b/src/AppBundle/Facade/MessageFacade.php
new file mode 100644
index 0000000..3be8f1c
--- /dev/null
+++ b/src/AppBundle/Facade/MessageFacade.php
@@ -0,0 +1,34 @@
+
+ */
+class MessageFacade {
+
+ /*
+ * @var MessageRepository
+ */
+ private $messageRepository;
+
+ /*
+ * @var EntityManager
+ */
+ private $entityManager;
+
+ public function __construct(MessageRepository $messageRepository, EntityManager $entityManager) {
+ $this->messageRepository = $messageRepository;
+ $this->entityManager = $entityManager;
+ }
+
+ public function saveMessage(Message $mmessage)
+ {
+ $this->entityManager->persist($mmessage);
+ $this->entityManager->flush([$mmessage]);
+ }
+}
diff --git a/src/AppBundle/FormType/MessageFormType.php b/src/AppBundle/FormType/MessageFormType.php
new file mode 100644
index 0000000..e89cfb0
--- /dev/null
+++ b/src/AppBundle/FormType/MessageFormType.php
@@ -0,0 +1,54 @@
+
+ */
+class MessageFormType extends AbstractType
+{
+
+ public function buildForm(FormBuilderInterface $builder, array $options)
+ {
+ $builder->add("name", TextType::class, [
+ "label" => "Meno",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ "constraints" => [
+ new NotBlank(["message" => "Prosím vyplňte Vaše meno"]),
+ ],
+ ])->add("email", TextType::class, [
+ "label" => "E-mail",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ "constraints" => [
+ new NotBlank(["message" => "Prosím vyplňte Váš email"]),
+ new Email(["message" => "Email nie je v správnom formáte"]),
+ ],
+ ])->add("message", TextareaType::class, [
+ "label" => "Správa",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ "constraints" => [
+ new NotBlank(["message" => "Prosím vyplňte správu"]),
+ ],
+ ])
+ ->add("submit", SubmitType::class, [
+ "label" => "Odoslať",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ]);
+ }
+
+}
\ No newline at end of file
diff --git a/src/AppBundle/Repository/FaqRepository.php b/src/AppBundle/Repository/FaqRepository.php
new file mode 100644
index 0000000..57ba774
--- /dev/null
+++ b/src/AppBundle/Repository/FaqRepository.php
@@ -0,0 +1,12 @@
+