diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig index 4f5d87e..940e10f 100644 --- a/app/Resources/views/base.html.twig +++ b/app/Resources/views/base.html.twig @@ -46,6 +46,12 @@
  • Domů
  • +
  • + FAQ +
  • +
  • + Kontakty +
  • Žádné zajímevé otázky a odpovědi

    + {% else %} + {% for faq in faqs %} +

    {{ faq.question|raw }}

    +

    {{ faq.answer|raw }}

    +
    + {% endfor %} + {% endif %} +{% endblock %} \ No newline at end of file diff --git a/app/config/services.yml b/app/config/services.yml index 59f9fb4..fe7e446 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -19,6 +19,14 @@ services: app.controller.user_controller: 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 @@ -31,11 +39,29 @@ services: app.facade.user_facade: 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] arguments: ['AppBundle\Entity\Category'] + + app.repository.faq_repository: + class: AppBundle\Repository\FaqRepository + factory: ['@doctrine.orm.default_entity_manager', getRepository] + arguments: ['AppBundle\Entity\Faq'] + + app.repository.contact_msg_repository: + class: AppBundle\Repository\ContactMsgRepository + factory: ['@doctrine.orm.default_entity_manager', getRepository] + arguments: ['AppBundle\Entity\ContactMsg'] app.repository.product_repository: class: AppBundle\Repository\ProductRepository diff --git a/src/AppBundle/Controller/ContactController.php b/src/AppBundle/Controller/ContactController.php new file mode 100644 index 0000000..f14cf66 --- /dev/null +++ b/src/AppBundle/Controller/ContactController.php @@ -0,0 +1,63 @@ +contactFacade = $contactFacade; + $this->userFacade = $userFacade; + $this->formFactory = $formFactory; + $this->router = $router; + } + + /** + * @Route("/kontakty", name="contact") + * @Template("contact/contact.html.twig") + * + * @param Request $request + * @return RedirectResponse|array + */ + public function contactAction(Request $request) + { + $msg = new ContactMsg(); + $msg->setUser($this->userFacade->getUser()); + $form = $this->formFactory->create(ContactFormType::class, $msg); + + $form->handleRequest($request); + if ($form->isSubmitted() && $form->isValid()) + { + $this->contactFacade->save($msg); + + return RedirectResponse::create($this->router->generate("homepage")); + } + + return [ + "form" => $form->createView(), + ]; + } + +} diff --git a/src/AppBundle/Controller/FaqController.php b/src/AppBundle/Controller/FaqController.php new file mode 100644 index 0000000..63af5db --- /dev/null +++ b/src/AppBundle/Controller/FaqController.php @@ -0,0 +1,46 @@ +faqFacade = $faqFacade; + $this->userFacade = $userFacade; + } + + /** + * @Route("/faq", name="faq") + * @Template("faq/faq.html.twig") + */ + public function faqAction() + { + $faqs = $this->faqFacade->getAll(); + + return [ + "faqs" => $faqs, + "user" => $this->userFacade->getUser(), + ]; + } + +} diff --git a/src/AppBundle/Entity/ContactMsg.php b/src/AppBundle/Entity/ContactMsg.php new file mode 100644 index 0000000..be519e1 --- /dev/null +++ b/src/AppBundle/Entity/ContactMsg.php @@ -0,0 +1,218 @@ +sendDate = new DateTime(); + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set msg + * + * @param string $msg + * + * @return ContactMsg + */ + public function setMsg($msg) + { + $this->msg = $msg; + + return $this; + } + + /** + * Get msg + * + * @return string + */ + public function getMsg() + { + return $this->msg; + } + + /** + * Set sendDate + * + * @param \DateTime $sendDate + * + * @return ContactMsg + */ + public function setSendDate($sendDate) + { + $this->sendDate = $sendDate; + + return $this; + } + + /** + * Get sendDate + * + * @return \DateTime + */ + public function getSendDate() + { + return $this->sendDate; + } + + /** + * Set user + * + * @param \AppBundle\Entity\User $user + * + * @return ContactMsg + */ + public function setUser(\AppBundle\Entity\User $user = null) + { + $this->user = $user; + + return $this; + } + + /** + * Get user + * + * @return \AppBundle\Entity\User + */ + public function getUser() + { + return $this->user; + } + + + /** + * Set subject + * + * @param string $subject + * + * @return ContactMsg + */ + public function setSubject($subject) + { + $this->subject = $subject; + + return $this; + } + + /** + * Get subject + * + * @return string + */ + public function getSubject() + { + return $this->subject; + } + + /** + * Set email + * + * @param string $email + * + * @return ContactMsg + */ + public function setEmail($email) + { + $this->email = $email; + + return $this; + } + + /** + * Get email + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * Set name + * + * @param string $name + * + * @return ContactMsg + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } +} diff --git a/src/AppBundle/Entity/Faq.php b/src/AppBundle/Entity/Faq.php new file mode 100644 index 0000000..4e3eea9 --- /dev/null +++ b/src/AppBundle/Entity/Faq.php @@ -0,0 +1,92 @@ +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 answer + * + * @param string $answer + * + * @return Faq + */ + public function setAnswer($answer) + { + $this->answer = $answer; + + return $this; + } + + /** + * Get answer + * + * @return string + */ + public function getAnswer() + { + return $this->answer; + } +} diff --git a/src/AppBundle/Entity/User.php b/src/AppBundle/Entity/User.php index b55cf83..6586bac 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; @@ -231,4 +231,27 @@ public function eraseCredentials() return; } + /** + * Add address + * + * @param \AppBundle\Entity\Address $address + * + * @return User + */ + public function addAddress(\AppBundle\Entity\Address $address) + { + $this->addresses[] = $address; + + return $this; + } + + /** + * Remove address + * + * @param \AppBundle\Entity\Address $address + */ + public function removeAddress(\AppBundle\Entity\Address $address) + { + $this->addresses->removeElement($address); + } } diff --git a/src/AppBundle/Facade/ContactFacade.php b/src/AppBundle/Facade/ContactFacade.php new file mode 100644 index 0000000..9a1add7 --- /dev/null +++ b/src/AppBundle/Facade/ContactFacade.php @@ -0,0 +1,26 @@ +contactMsgRepository = $contactMsgRepository; + $this->entityManager = $entityManager; + } + + public function save($msg) + { + $this->entityManager->persist($msg); + $this->entityManager->flush([$msg]); + } + +} diff --git a/src/AppBundle/Facade/FaqFacade.php b/src/AppBundle/Facade/FaqFacade.php new file mode 100644 index 0000000..811d4fe --- /dev/null +++ b/src/AppBundle/Facade/FaqFacade.php @@ -0,0 +1,27 @@ +faqRepository = $faqRepository; + } + + public function getAll() + { + return $this->faqRepository->findBy( + [], [ + "question" => "asc" + ] + ); + } + +} diff --git a/src/AppBundle/FormType/ContactFormType.php b/src/AppBundle/FormType/ContactFormType.php new file mode 100644 index 0000000..4c0441d --- /dev/null +++ b/src/AppBundle/FormType/ContactFormType.php @@ -0,0 +1,51 @@ +add("name", TextType::class, [ + "label" => "Jméno", + "attr" => [ + "class" => "form-control", + ], + ]) + ->add("email", EmailType::class, [ + "label" => "Email", + "attr" => [ + "class" => "form-control", + ], + ]) + ->add("subject", TextType::class, [ + "label" => "Předmět", + "attr" => [ + "class" => "form-control", + ], + ]) + ->add("msg", TextType::class, [ + "label" => "Zpráva", + "attr" => [ + "class" => "form-control", + ], + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + "data_class" => ContactMsg::class, + )); + } + +} diff --git a/src/AppBundle/Repository/ContactMsgRepository.php b/src/AppBundle/Repository/ContactMsgRepository.php new file mode 100644 index 0000000..eaba006 --- /dev/null +++ b/src/AppBundle/Repository/ContactMsgRepository.php @@ -0,0 +1,9 @@ +