Readme
parent
923854fa31
commit
0dce310a6c
|
@ -39,3 +39,9 @@ Build assets
|
||||||
~~~
|
~~~
|
||||||
make front-build
|
make front-build
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
Load test data fixtures
|
||||||
|
|
||||||
|
~~~
|
||||||
|
php bin/console doctrine:fixture:load
|
||||||
|
~~~
|
|
@ -1,90 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controller;
|
|
||||||
|
|
||||||
use App\Entity\Question;
|
|
||||||
use App\Form\QuestionType;
|
|
||||||
use App\Repository\QuestionRepository;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/admin/question")
|
|
||||||
*/
|
|
||||||
class QuestionController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @Route("/", name="question_index", methods="GET")
|
|
||||||
*/
|
|
||||||
public function index(QuestionRepository $questionRepository): Response
|
|
||||||
{
|
|
||||||
return $this->render('question/index.html.twig', ['questions' => $questionRepository->findAll()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/new", name="question_new", methods="GET|POST")
|
|
||||||
*/
|
|
||||||
public function new(Request $request): Response
|
|
||||||
{
|
|
||||||
$question = new Question();
|
|
||||||
$form = $this->createForm(QuestionType::class, $question);
|
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$em->persist($question);
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
return $this->redirectToRoute('question_index');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('question/new.html.twig', [
|
|
||||||
'question' => $question,
|
|
||||||
'form' => $form->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{id}", name="question_show", methods="GET")
|
|
||||||
*/
|
|
||||||
public function show(Question $question): Response
|
|
||||||
{
|
|
||||||
return $this->render('question/show.html.twig', ['question' => $question]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{id}/edit", name="question_edit", methods="GET|POST")
|
|
||||||
*/
|
|
||||||
public function edit(Request $request, Question $question): Response
|
|
||||||
{
|
|
||||||
$form = $this->createForm(QuestionType::class, $question);
|
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
|
||||||
$this->getDoctrine()->getManager()->flush();
|
|
||||||
|
|
||||||
return $this->redirectToRoute('question_edit', ['id' => $question->getId()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('question/edit.html.twig', [
|
|
||||||
'question' => $question,
|
|
||||||
'form' => $form->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{id}", name="question_delete", methods="DELETE")
|
|
||||||
*/
|
|
||||||
public function delete(Request $request, Question $question): Response
|
|
||||||
{
|
|
||||||
if ($this->isCsrfTokenValid('delete'.$question->getId(), $request->request->get('_token'))) {
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$em->remove($question);
|
|
||||||
$em->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->redirectToRoute('question_index');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controller;
|
|
||||||
|
|
||||||
use App\Entity\Response;
|
|
||||||
use App\Form\ResponseType;
|
|
||||||
use App\Repository\ResponseRepository;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response as HttpResponse;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/admin/response")
|
|
||||||
*/
|
|
||||||
class ResponseController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @Route("/", name="response_index", methods="GET")
|
|
||||||
*/
|
|
||||||
public function index(ResponseRepository $responseRepository): HttpResponse
|
|
||||||
{
|
|
||||||
return $this->render('response/index.html.twig', ['responses' => $responseRepository->findAll()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/new", name="response_new", methods="GET|POST")
|
|
||||||
*/
|
|
||||||
public function new(Request $request): HttpResponse
|
|
||||||
{
|
|
||||||
$response = new Response();
|
|
||||||
$form = $this->createForm(ResponseType::class, $response);
|
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$em->persist($response);
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
return $this->redirectToRoute('response_index');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('response/new.html.twig', [
|
|
||||||
'response' => $response,
|
|
||||||
'form' => $form->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{id}", name="response_show", methods="GET")
|
|
||||||
*/
|
|
||||||
public function show(Response $response): HttpResponse
|
|
||||||
{
|
|
||||||
return $this->render('response/show.html.twig', ['response' => $response]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{id}/edit", name="response_edit", methods="GET|POST")
|
|
||||||
*/
|
|
||||||
public function edit(Request $request, Response $response): HttpResponse
|
|
||||||
{
|
|
||||||
$form = $this->createForm(ResponseType::class, $response);
|
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
|
||||||
$this->getDoctrine()->getManager()->flush();
|
|
||||||
|
|
||||||
return $this->redirectToRoute('response_edit', ['id' => $response->getId()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('response/edit.html.twig', [
|
|
||||||
'response' => $response,
|
|
||||||
'form' => $form->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{id}", name="response_delete", methods="DELETE")
|
|
||||||
*/
|
|
||||||
public function delete(Request $request, Response $response): HttpResponse
|
|
||||||
{
|
|
||||||
if ($this->isCsrfTokenValid('delete'.$response->getId(), $request->request->get('_token'))) {
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$em->remove($response);
|
|
||||||
$em->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->redirectToRoute('response_index');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>{% block title %}Welcome!{% endblock %}</title>
|
|
||||||
{% block stylesheets %}{% endblock %}
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{% block body %}{% endblock %}
|
|
||||||
{% block javascripts %}{% endblock %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,5 +0,0 @@
|
||||||
<form method="post" action="{{ path('question_delete', {'id': question.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
|
|
||||||
<input type="hidden" name="_method" value="DELETE">
|
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ question.id) }}">
|
|
||||||
<button class="btn">Delete</button>
|
|
||||||
</form>
|
|
|
@ -1,4 +0,0 @@
|
||||||
{{ form_start(form) }}
|
|
||||||
{{ form_widget(form) }}
|
|
||||||
<button class="btn">{{ button_label|default('Save') }}</button>
|
|
||||||
{{ form_end(form) }}
|
|
|
@ -1,13 +0,0 @@
|
||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% block title %}Edit Question{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<h1>Edit Question</h1>
|
|
||||||
|
|
||||||
{{ include('question/_form.html.twig', {'button_label': 'Update'}) }}
|
|
||||||
|
|
||||||
<a href="{{ path('question_index') }}">back to list</a>
|
|
||||||
|
|
||||||
{{ include('question/_delete_form.html.twig') }}
|
|
||||||
{% endblock %}
|
|
|
@ -1,37 +0,0 @@
|
||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% block title %}Question index{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<h1>Question index</h1>
|
|
||||||
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Id</th>
|
|
||||||
<th>Text</th>
|
|
||||||
<th>Date</th>
|
|
||||||
<th>actions</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for question in questions %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ question.id }}</td>
|
|
||||||
<td>{{ question.text }}</td>
|
|
||||||
<td>{{ question.date ? question.date|date('Y-m-d H:i:s') : '' }}</td>
|
|
||||||
<td>
|
|
||||||
<a href="{{ path('question_show', {'id': question.id}) }}">show</a>
|
|
||||||
<a href="{{ path('question_edit', {'id': question.id}) }}">edit</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% else %}
|
|
||||||
<tr>
|
|
||||||
<td colspan="5">no records found</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<a href="{{ path('question_new') }}">Create new</a>
|
|
||||||
{% endblock %}
|
|
|
@ -1,11 +0,0 @@
|
||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% block title %}New Question{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<h1>Create new Question</h1>
|
|
||||||
|
|
||||||
{{ include('question/_form.html.twig') }}
|
|
||||||
|
|
||||||
<a href="{{ path('question_index') }}">back to list</a>
|
|
||||||
{% endblock %}
|
|
|
@ -1,30 +0,0 @@
|
||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% block title %}Question{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<h1>Question</h1>
|
|
||||||
|
|
||||||
<table class="table">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<th>Id</th>
|
|
||||||
<td>{{ question.id }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Text</th>
|
|
||||||
<td>{{ question.text }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Date</th>
|
|
||||||
<td>{{ question.date ? question.date|date('Y-m-d H:i:s') : '' }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<a href="{{ path('question_index') }}">back to list</a>
|
|
||||||
|
|
||||||
<a href="{{ path('question_edit', {'id': question.id}) }}">edit</a>
|
|
||||||
|
|
||||||
{{ include('question/_delete_form.html.twig') }}
|
|
||||||
{% endblock %}
|
|
|
@ -1,5 +0,0 @@
|
||||||
<form method="post" action="{{ path('response_delete', {'id': response.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
|
|
||||||
<input type="hidden" name="_method" value="DELETE">
|
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ response.id) }}">
|
|
||||||
<button class="btn">Delete</button>
|
|
||||||
</form>
|
|
|
@ -1,4 +0,0 @@
|
||||||
{{ form_start(form) }}
|
|
||||||
{{ form_widget(form) }}
|
|
||||||
<button class="btn">{{ button_label|default('Save') }}</button>
|
|
||||||
{{ form_end(form) }}
|
|
|
@ -1,13 +0,0 @@
|
||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% block title %}Edit Response{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<h1>Edit Response</h1>
|
|
||||||
|
|
||||||
{{ include('response/_form.html.twig', {'button_label': 'Update'}) }}
|
|
||||||
|
|
||||||
<a href="{{ path('response_index') }}">back to list</a>
|
|
||||||
|
|
||||||
{{ include('response/_delete_form.html.twig') }}
|
|
||||||
{% endblock %}
|
|
|
@ -1,35 +0,0 @@
|
||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% block title %}Response index{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<h1>Response index</h1>
|
|
||||||
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Id</th>
|
|
||||||
<th>Text</th>
|
|
||||||
<th>actions</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for response in responses %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ response.id }}</td>
|
|
||||||
<td>{{ response.text }}</td>
|
|
||||||
<td>
|
|
||||||
<a href="{{ path('response_show', {'id': response.id}) }}">show</a>
|
|
||||||
<a href="{{ path('response_edit', {'id': response.id}) }}">edit</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% else %}
|
|
||||||
<tr>
|
|
||||||
<td colspan="3">no records found</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<a href="{{ path('response_new') }}">Create new</a>
|
|
||||||
{% endblock %}
|
|
|
@ -1,11 +0,0 @@
|
||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% block title %}New Response{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<h1>Create new Response</h1>
|
|
||||||
|
|
||||||
{{ include('response/_form.html.twig') }}
|
|
||||||
|
|
||||||
<a href="{{ path('response_index') }}">back to list</a>
|
|
||||||
{% endblock %}
|
|
|
@ -1,26 +0,0 @@
|
||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% block title %}Response{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<h1>Response</h1>
|
|
||||||
|
|
||||||
<table class="table">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<th>Id</th>
|
|
||||||
<td>{{ response.id }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Text</th>
|
|
||||||
<td>{{ response.text }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<a href="{{ path('response_index') }}">back to list</a>
|
|
||||||
|
|
||||||
<a href="{{ path('response_edit', {'id': response.id}) }}">edit</a>
|
|
||||||
|
|
||||||
{{ include('response/_delete_form.html.twig') }}
|
|
||||||
{% endblock %}
|
|
Loading…
Reference in New Issue