diff --git a/.gitignore b/.gitignore
index 947ec6a..a9b5776 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,4 @@
/vendor/
/web/bundles/
composer.lock
+composer.phar
diff --git a/app/Resources/views/Contact/contact.html.twig b/app/Resources/views/Contact/contact.html.twig
new file mode 100644
index 0000000..04e4b0c
--- /dev/null
+++ b/app/Resources/views/Contact/contact.html.twig
@@ -0,0 +1,10 @@
+{% extends "::base.html.twig" %}
+
+{% block body %}
+ {{ include('::alert.html.twig') }}
+
Kontaktujte nás
+ {{ form_start(form) }}
+ {{ form_widget(form) }}
+ Odeslat!
+ {{ form_end(form) }}
+{% endblock %}
diff --git a/app/Resources/views/Faq/faqs.html.twig b/app/Resources/views/Faq/faqs.html.twig
new file mode 100644
index 0000000..c4a9a8e
--- /dev/null
+++ b/app/Resources/views/Faq/faqs.html.twig
@@ -0,0 +1,26 @@
+{% extends "::base.html.twig" %}
+
+{% block body %}
+Frequently Asked Questions
+
+ {% for faq in allFaqs %}
+
+
+
+
+ {{ faq.response }}
+
+
+
+ {% endfor %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/Resources/views/alert.html.twig b/app/Resources/views/alert.html.twig
new file mode 100644
index 0000000..f5ca7d4
--- /dev/null
+++ b/app/Resources/views/alert.html.twig
@@ -0,0 +1,7 @@
+{% for type, flashes in app.session.flashbag.all %}
+ {% for flash in flashes %}
+
+ {{ flash }}
+
+ {% endfor %}
+{% endfor %}
\ No newline at end of file
diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig
index 4f5d87e..61ac6d2 100644
--- a/app/Resources/views/base.html.twig
+++ b/app/Resources/views/base.html.twig
@@ -56,6 +56,10 @@
| Registrovat
{% endif %}
+
+ Kontakt
+ | FAQ
+
diff --git a/app/config/services.yml b/app/config/services.yml
index 59f9fb4..386d59d 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.contact_controller:
+ class: AppBundle\Controller\ContactController
+ autowire: true
+
app.facade.category_facade:
class: AppBundle\Facade\CategoryFacade
autowire: true
@@ -32,6 +40,14 @@ services:
class: AppBundle\Facade\UserFacade
autowire: true
+ app.facade.faq_facade:
+ class: AppBundle\Facade\FaqFacade
+ autowire: true
+
+ app.facade.contact_facade:
+ class: AppBundle\Facade\ContactFacade
+ autowire: true
+
app.repository.category_repository:
class: AppBundle\Repository\CategoryRepository
factory: ['@doctrine.orm.default_entity_manager', getRepository]
@@ -42,6 +58,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.contact_repository:
+ class: AppBundle\Repository\ContactRepository
+ factory: ['@doctrine.orm.default_entity_manager', getRepository]
+ arguments: ['AppBundle\Entity\Contact']
+
encoder:
class: Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder
arguments:
diff --git a/src/AppBundle/Controller/ContactController.php b/src/AppBundle/Controller/ContactController.php
new file mode 100644
index 0000000..8ae0d21
--- /dev/null
+++ b/src/AppBundle/Controller/ContactController.php
@@ -0,0 +1,74 @@
+contactFacade = $contactFacade;
+ $this->formFactory = $formFactory;
+ $this->router = $router;
+ }
+
+ /**
+ * @Route("/contact", name="contact")
+ * @Template("contact/contact.html.twig")
+ *
+ * @param Request $request
+ * @return RedirectResponse|array
+ */
+ public function contactAction(Request $request)
+ {
+ $contact = new Contact();
+ $form = $this->formFactory->create(ContactFormType::class, $contact);
+
+ $form->handleRequest($request);
+ if ($form->isSubmitted() && $form->isValid()) {
+
+ $contact = $this->contactFacade->setNewContactMessage($contact);
+ if(null != $contact->getId()) {
+ $request->getSession()->getFlashBag()->add(
+ 'success',
+ 'Vaše zpráva byla odeslána'
+ );
+ } else {
+ $request->getSession()->getFlashBag()->add(
+ 'error',
+ 'Vaše nebyla odeslána. Zkuste to prosím znovu.'
+ );
+ }
+
+ return RedirectResponse::create($this->router->generate("contact"));
+
+
+ }
+
+ return [
+ "form" => $form->createView(),
+ ];
+ }
+
+}
diff --git a/src/AppBundle/Controller/FaqController.php b/src/AppBundle/Controller/FaqController.php
new file mode 100644
index 0000000..0340d59
--- /dev/null
+++ b/src/AppBundle/Controller/FaqController.php
@@ -0,0 +1,35 @@
+faqFacade = $faqFacade;
+ }
+
+ /**
+ * @Route("/faqs", name="faqs")
+ * @Template("faq/faqs.html.twig")
+ */
+ public function readFaqsAction()
+ {
+ $allFaqs = $this->faqFacade->getAllFaqs();
+
+ return [
+ "allFaqs" => $allFaqs
+ ];
+ }
+
+}
diff --git a/src/AppBundle/Entity/Contact.php b/src/AppBundle/Entity/Contact.php
new file mode 100644
index 0000000..0be50d7
--- /dev/null
+++ b/src/AppBundle/Entity/Contact.php
@@ -0,0 +1,117 @@
+id;
+ }
+
+ /**
+ * @param int $id
+ * @return Contact
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+ return $this;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param mixed $name
+ * @return Contact
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * @param mixed $email
+ * @return Contact
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;
+ return $this;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getMessage()
+ {
+ return $this->message;
+ }
+
+ /**
+ * @param mixed $message
+ * @return Contact
+ */
+ public function setMessage($message)
+ {
+ $this->message = $message;
+ return $this;
+ }
+
+
+}
+
diff --git a/src/AppBundle/Entity/Faq.php b/src/AppBundle/Entity/Faq.php
new file mode 100644
index 0000000..c0bf2e5
--- /dev/null
+++ b/src/AppBundle/Entity/Faq.php
@@ -0,0 +1,99 @@
+id;
+ }
+
+ /**
+ * Set question
+ *
+ * @param string $question
+ *
+ * @return Faq
+ */
+ public function setQuestion($question)
+ {
+ $this->question = $question;
+
+ return $this;
+ }
+
+ /**
+ * Get question
+ *
+ * @return string
+ */
+ public function getQuestion()
+ {
+ return $this->question;
+ }
+
+ /**
+ * Set response
+ *
+ * @param string $response
+ *
+ * @return Faq
+ */
+ public function setResponse($response)
+ {
+ $this->response = $response;
+
+ return $this;
+ }
+
+ /**
+ * Get response
+ *
+ * @return string
+ */
+ public function getResponse()
+ {
+ return $this->response;
+ }
+}
+
diff --git a/src/AppBundle/Entity/User.php b/src/AppBundle/Entity/User.php
index b55cf83..6384b3b 100644
--- a/src/AppBundle/Entity/User.php
+++ b/src/AppBundle/Entity/User.php
@@ -44,19 +44,19 @@ class User implements UserInterface
/**
* @var string
- * @ORM\Column(type="string")
+ * @ORM\Column(type="string", nullable=true)
*/
private $firstName;
/**
* @var string
- * @ORM\Column(type="string")
+ * @ORM\Column(type="string", nullable=true)
*/
private $lastName;
/**
* @var string
- * @ORM\Column(type="string")
+ * @ORM\Column(type="string", nullable=true)
*/
private $phone;
diff --git a/src/AppBundle/Facade/ContactFacade.php b/src/AppBundle/Facade/ContactFacade.php
new file mode 100644
index 0000000..553bd2c
--- /dev/null
+++ b/src/AppBundle/Facade/ContactFacade.php
@@ -0,0 +1,28 @@
+contactRepository = $contactRepository;
+ $this->entityManager = $entityManager;
+ }
+
+ public function setNewContactMessage($contact) {
+ $this->entityManager->persist($contact);
+ $this->entityManager->flush([$contact]);
+ return $contact;
+ }
+
+
+}
\ 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..fc05ff4
--- /dev/null
+++ b/src/AppBundle/Facade/FaqFacade.php
@@ -0,0 +1,22 @@
+faqRepository = $faqRepository;
+ }
+
+ /** @return Faq[] */
+ public function getAllFaqs() {
+ return $this->faqRepository->findAll();
+ }
+
+
+}
\ 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..4c691d2
--- /dev/null
+++ b/src/AppBundle/FormType/ContactFormType.php
@@ -0,0 +1,65 @@
+add("name", TextType::class, [
+ "label" => "Jméno",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ "constraints" => [
+ new NotBlank(["message" => "Prosím vyplňte Vaše jméno"]),
+ ],
+ ])->add("email", TextType::class, [
+ "label" => "Email",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ "constraints" => [
+ new NotBlank(["message" => "Prosím vyplňte Váš email"]),
+ ],
+ ])->add("message", TextareaType::class, [
+ "label" => "Zpráva",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ "constraints" => [
+ new NotBlank(["message" => "Prosím vyplňte Vaši zprávu"]),
+ ],
+ ]);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'data_class' => 'AppBundle\Entity\Contact'
+ ));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBlockPrefix()
+ {
+ return 'appbundle_contact';
+ }
+
+
+}
diff --git a/src/AppBundle/Repository/ContactRepository.php b/src/AppBundle/Repository/ContactRepository.php
new file mode 100644
index 0000000..7f85397
--- /dev/null
+++ b/src/AppBundle/Repository/ContactRepository.php
@@ -0,0 +1,15 @@
+request('GET', '/contact');
+ }
+
+}
diff --git a/src/AppBundle/Tests/Controller/FaqControllerTest.php b/src/AppBundle/Tests/Controller/FaqControllerTest.php
new file mode 100644
index 0000000..080e993
--- /dev/null
+++ b/src/AppBundle/Tests/Controller/FaqControllerTest.php
@@ -0,0 +1,16 @@
+request('GET', '/faqs');
+ }
+
+}
diff --git a/web/config.php b/web/config.php
index 1368c8a..a031a3a 100644
--- a/web/config.php
+++ b/web/config.php
@@ -38,9 +38,216 @@
Symfony Configuration Checker
-
-
-