-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ukol 4 - Jozef Liška #35
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block body %} | ||
<h1>FAQ</h1> | ||
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | ||
{% for item in faq %} | ||
<div class="panel panel-default"> | ||
<div class="panel-heading" role="tab" id="heading{{ item.id }}"> | ||
<h4 class="panel-title"> | ||
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{ item.id }}" aria-expanded="false" aria-controls="collapse{{ item.id }}"> | ||
{{ item.question }} | ||
</a> | ||
</h4> | ||
</div> | ||
<div id="collapse{{ item.id }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading{{ item.id }}"> | ||
<div class="panel-body"> | ||
{{ item.answer }} | ||
</div> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block body %} | ||
<h1>Kontakt</h1> | ||
{{ form(form) }} | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace AppBundle\Controller; | ||
|
||
use AppBundle\Facade\FaqFacade; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; | ||
|
||
/** | ||
* @author Jozef Liška <[email protected]> | ||
* @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() | ||
]; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
namespace AppBundle\Controller; | ||
|
||
use AppBundle\Entity\Message; | ||
use AppBundle\Facade\MessageFacade; | ||
use AppBundle\FormType\MessageFormType; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; | ||
use Symfony\Component\Form\FormFactory; | ||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\Routing\RouterInterface; | ||
|
||
|
||
/** | ||
* @author Jozef Liška <[email protected]> | ||
* @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(), | ||
]; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace AppBundle\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @author Jozef Liška <[email protected]> | ||
* | ||
* @ORM\Entity(repositoryClass="AppBundle\Repository\FaqRepository") | ||
*/ | ||
class Faq | ||
{ | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indent |
||
* @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; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
|
||
namespace AppBundle\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
/** | ||
* @author Jozef Liška <[email protected]> | ||
* | ||
* @ORM\Entity(repositoryClass="AppBundle\Repository\MessageRepository") | ||
*/ | ||
class Message | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Byl bych možná opatrný s použitím takto obecných slov... |
||
{ | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indent :) |
||
* @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; | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indent |
||
* @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; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent