diff --git a/app/Resources/views/contact/contact.html.twig b/app/Resources/views/contact/contact.html.twig new file mode 100644 index 0000000..27091ef --- /dev/null +++ b/app/Resources/views/contact/contact.html.twig @@ -0,0 +1,12 @@ +{% extends 'base.html.twig' %} + +{% block body %} + {{ form_start(form) }} + {{ form_row(form.firstName) }} + {{ form_row(form.surname) }} + {{ form_row(form.email) }} + {{ form_row(form.query) }} +
+ + {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/app/Resources/views/faq/faq.html.twig b/app/Resources/views/faq/faq.html.twig new file mode 100644 index 0000000..3bc1a33 --- /dev/null +++ b/app/Resources/views/faq/faq.html.twig @@ -0,0 +1,20 @@ +{% extends 'base.html.twig' %} + +{% block body %} +
+ {% for f in faq %} +
+ +
+
+ {{ f.reply }} +
+
+
+ {% endfor %} +
+{% endblock %} diff --git a/app/config/services.yml b/app/config/services.yml index 59f9fb4..38ef124 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 @@ -31,7 +39,15 @@ services: app.facade.user_facade: class: AppBundle\Facade\UserFacade autowire: true - + + app.facade.faq_facade: + class: AppBundle\Facade\FaqFacade + autowire: true + + app.facade.faq_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..a37410d --- /dev/null +++ b/src/AppBundle/Controller/ContactController.php @@ -0,0 +1,55 @@ +contactFacade = $contactFacade; + $this->formFactory = $formFactory; + $this->entityManager = $entityManager; + } + + /** + * @Route("/contact", name="contact") + * @Template("contact/contact.html.twig") + * + * @param Request $request + * @return array + */ + public function contactAction(Request $request) { + $contact = new Contact(); + $form = $this->formFactory->create(ContactFormType::class, $contact); + + $form->handleRequest($request); + if ($form->isSubmitted() && $form->isValid()) { + $this->entityManager->persist($contact); + $this->entityManager->flush([$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..7879afa --- /dev/null +++ b/src/AppBundle/Controller/FaqController.php @@ -0,0 +1,33 @@ +faqFacade = $faqFacade; + } + + /** + * @Route("/faq", name="faq") + * @Template("faq/faq.html.twig") + */ + public function faqAction() { + $faq = $this->faqFacade->getAll(); + return [ + 'faq' => $faq + ]; + } + +} diff --git a/src/AppBundle/Entity/Contact.php b/src/AppBundle/Entity/Contact.php new file mode 100644 index 0000000..dd129d2 --- /dev/null +++ b/src/AppBundle/Entity/Contact.php @@ -0,0 +1,124 @@ +id; + } + + /** + * @param int $id + * @return self + */ + public function setId($id) { + $this->id = $id; + 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 getFirstName() { + return $this->firstName; + } + + /** + * @param string $firstName + * @return self + */ + public function setFirstName($firstName) { + $this->firstName = $firstName; + return $this; + } + + /** + * @return string + */ + public function getSurname() { + return $this->surname; + } + + /** + * @param string $surname + * @return self + */ + public function setSurname($surname) { + $this->surname = $surname; + return $this; + } + + /** + * @return string + */ + public function getQuery() { + return $this->query; + } + + /** + * @param string $query + * @return self + */ + public function setQuery($query) { + $this->query = $query; + return $this; + } +} diff --git a/src/AppBundle/Entity/Faq.php b/src/AppBundle/Entity/Faq.php new file mode 100644 index 0000000..6cc26b0 --- /dev/null +++ b/src/AppBundle/Entity/Faq.php @@ -0,0 +1,81 @@ +id; + } + + /** + * @param int $id + * @return self + */ + public function setId($id) { + $this->id = $id; + return $this; + } + + /** + * @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 getReply() { + return $this->reply; + } + + /** + * @param string $reply + * @return self + */ + public function setReply($reply) { + $this->reply = $reply; + return $this; + } + +} diff --git a/src/AppBundle/Facade/ContactFacade.php b/src/AppBundle/Facade/ContactFacade.php new file mode 100644 index 0000000..f962f6c --- /dev/null +++ b/src/AppBundle/Facade/ContactFacade.php @@ -0,0 +1,18 @@ +contactRepository = $contactRepository; + } + +} diff --git a/src/AppBundle/Facade/FaqFacade.php b/src/AppBundle/Facade/FaqFacade.php new file mode 100644 index 0000000..87bf4a6 --- /dev/null +++ b/src/AppBundle/Facade/FaqFacade.php @@ -0,0 +1,22 @@ +faqRepository = $faqRepository; + } + + public function getAll() { + return $this->faqRepository->findAll(); + } + +} diff --git a/src/AppBundle/FormType/ContactFormType.php b/src/AppBundle/FormType/ContactFormType.php new file mode 100644 index 0000000..7dfc87a --- /dev/null +++ b/src/AppBundle/FormType/ContactFormType.php @@ -0,0 +1,50 @@ +add("email", EmailType::class, [ + "label" => "E-mail", + "attr" => [ + "class" => "form-control", + ], + ])->add("firstName", TextType::class, [ + "label" => "Jméno", + "attr" => [ + "class" => "form-control", + ], + "constraints" => [ + new NotBlank(["message" => "Prosím vyplňte Vaše jméno"]), + ] + ])->add("surname", TextType::class, [ + "label" => "Příjmení", + "attr" => [ + "class" => "form-control", + ], + "constraints" => [ + new NotBlank(["message" => "Prosím vyplňte Vaše příjmení"]), + ] + ])->add("query", TextType::class, [ + "label" => "Dotaz", + "attr" => [ + "class" => "form-control", + ], + "constraints" => [ + new NotBlank(["message" => "Prosím vyplňte Váš dotaz"]), + ] + ]); + } +} \ No newline at end of file diff --git a/src/AppBundle/Repository/ContactRepository.php b/src/AppBundle/Repository/ContactRepository.php new file mode 100644 index 0000000..aeda507 --- /dev/null +++ b/src/AppBundle/Repository/ContactRepository.php @@ -0,0 +1,9 @@ +