Skip to content

Ukol 4 - Vojtěch Havlíček #43

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/Resources/views/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
<li>
<a href="{{ path("homepage") }}">Domů</a>
</li>
<li>
<a href="{{ path("faq") }}">FAQ</a>
</li>
<li>
<a href="{{ path("contact") }}">Kontakt</a>
</li>
</ul>
<p class="navbar-text navbar-right">
{% if user is defined and user %}
Expand Down
11 changes: 11 additions & 0 deletions app/Resources/views/components/contactform.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends 'base.html.twig' %}

{% block body %}
{{ form_start(form) }}
{{ form_row(form.name) }}
{{ form_row(form.subject) }}
{{ form_row(form.message) }}
<br />
<button class="btn btn-lg btn-primary btn-block" type="submit">Odeslat</button>
{{ form_end(form) }}
{% endblock %}
15 changes: 15 additions & 0 deletions app/Resources/views/faq/faq.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends 'base.html.twig' %}

{% block body %}
{% for faq_item in faq %}
<div class="col-sm-12 col-lg-12 col-md-12">
<div class="question">
<h3>{{ faq_item.question }}</h3>
</div>
<div class="answer">
{{ faq_item.answer }}
</div>
<hr/>
</div>
{% endfor %}
{% endblock %}
13 changes: 13 additions & 0 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ services:
class: AppBundle\Controller\UserController
autowire: true

app.controller.faq_controller:
class: AppBundle\Controller\FAQController
autowire: true

app.facade.category_facade:
class: AppBundle\Facade\CategoryFacade
autowire: true
Expand All @@ -32,6 +36,10 @@ services:
class: AppBundle\Facade\UserFacade
autowire: true

app.facade.faq_facade:
class: AppBundle\Facade\FAQFacade
autowire: true

app.repository.category_repository:
class: AppBundle\Repository\CategoryRepository
factory: ['@doctrine.orm.default_entity_manager', getRepository]
Expand All @@ -42,6 +50,11 @@ 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']

encoder:
class: Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder
arguments:
Expand Down
37 changes: 37 additions & 0 deletions src/AppBundle/Controller/FAQController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace AppBundle\Controller;

use AppBundle\Facade\FAQFacade;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
* @Route(service="app.controller.faq_controller")
*/
class FAQController
{
private $faqFacade;

public function __construct(FAQFacade $faqFacade)
{
$this->faqFacade = $faqFacade;
}

/**
* @Route("/faq", name="faq")
* @Template("faq/faq.html.twig")
*/
public function faqDetailAction()
{
$faq = $this->faqFacade->getAll();
if (!$faq) {
throw new NotFoundHttpException("Žádné otázky a odpovědi nenalezeny.");
}

return [
"faq" => $faq,
];
}
}
128 changes: 128 additions & 0 deletions src/AppBundle/Entity/ContactForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* ContactForm
*
* @ORM\Table(name="contact_form")
* @ORM\Entity(repositoryClass="AppBundle\Repository\ContactFormRepository")
*/
class ContactForm
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;

/**
* @var string
*
* @ORM\Column(name="Name", type="string", length=150)
*/
private $name;

/**
* @var string
*
* @ORM\Column(name="Subject", type="string", length=150)
*/
private $subject;

/**
* @var string
*
* @ORM\Column(name="Message", type="string", length=1000)
*/
private $message;


/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* Set name
*
* @param string $name
*
* @return ContactForm
*/
public function setName($name)
{
$this->name = $name;

return $this;
}

/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}

/**
* Set subject
*
* @param string $subject
*
* @return ContactForm
*/
public function setSubject($subject)
{
$this->subject = $subject;

return $this;
}

/**
* Get subject
*
* @return string
*/
public function getSubject()
{
return $this->subject;
}

/**
* Set message
*
* @param string $message
*
* @return ContactForm
*/
public function setMessage($message)
{
$this->message = $message;

return $this;
}

/**
* Get message
*
* @return string
*/
public function getMessage()
{
return $this->message;
}
}

97 changes: 97 additions & 0 deletions src/AppBundle/Entity/FAQ.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* FAQ
*
* @ORM\Table(name="f_a_q")
* @ORM\Entity(repositoryClass="AppBundle\Repository\FAQRepository")
*/
class FAQ
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;

/**
* @var string
*
* @ORM\Column(name="question", type="string", length=255)
*/
private $question;

/**
* @var string
*
* @ORM\Column(name="answer", type="string", length=1000)
*/
private $answer;


/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->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;
}
}

20 changes: 20 additions & 0 deletions src/AppBundle/Facade/FAQFacade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace AppBundle\Facade;

use AppBundle\Repository\FAQRepository;


class FAQFacade
{
private $faqRepository;

public function __construct(FAQRepository $faqRepository) {
$this->faqRepository = $faqRepository;
}

public function getAll() {
return $this->faqRepository->findBy([]);
}

}
Loading