diff --git a/README.md b/README.md index 1dd004b..5f43049 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,9 @@ Build assets ~~~ make front-build ~~~ + +Load test data fixtures + +~~~ +php bin/console doctrine:fixture:load +~~~ \ No newline at end of file diff --git a/src/Controller/QuestionController.php b/src/Controller/QuestionController.php deleted file mode 100644 index c4cbd7b..0000000 --- a/src/Controller/QuestionController.php +++ /dev/null @@ -1,90 +0,0 @@ -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'); - } -} diff --git a/src/Controller/ResponseController.php b/src/Controller/ResponseController.php deleted file mode 100644 index 445971c..0000000 --- a/src/Controller/ResponseController.php +++ /dev/null @@ -1,90 +0,0 @@ -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'); - } -} diff --git a/templates/base.html.twig b/templates/base.html.twig deleted file mode 100644 index 043f42d..0000000 --- a/templates/base.html.twig +++ /dev/null @@ -1,12 +0,0 @@ - - - - - {% block title %}Welcome!{% endblock %} - {% block stylesheets %}{% endblock %} - - - {% block body %}{% endblock %} - {% block javascripts %}{% endblock %} - - diff --git a/templates/question/_delete_form.html.twig b/templates/question/_delete_form.html.twig deleted file mode 100644 index 466f65f..0000000 --- a/templates/question/_delete_form.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -
- - - -
\ No newline at end of file diff --git a/templates/question/_form.html.twig b/templates/question/_form.html.twig deleted file mode 100644 index 92948ad..0000000 --- a/templates/question/_form.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -{{ form_start(form) }} - {{ form_widget(form) }} - -{{ form_end(form) }} \ No newline at end of file diff --git a/templates/question/edit.html.twig b/templates/question/edit.html.twig deleted file mode 100644 index d13e9d8..0000000 --- a/templates/question/edit.html.twig +++ /dev/null @@ -1,13 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Edit Question{% endblock %} - -{% block body %} -

Edit Question

- - {{ include('question/_form.html.twig', {'button_label': 'Update'}) }} - - back to list - - {{ include('question/_delete_form.html.twig') }} -{% endblock %} \ No newline at end of file diff --git a/templates/question/index.html.twig b/templates/question/index.html.twig deleted file mode 100644 index b12bed8..0000000 --- a/templates/question/index.html.twig +++ /dev/null @@ -1,37 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Question index{% endblock %} - -{% block body %} -

Question index

- - - - - - - - - - - - {% for question in questions %} - - - - - - - {% else %} - - - - {% endfor %} - -
IdTextDateactions
{{ question.id }}{{ question.text }}{{ question.date ? question.date|date('Y-m-d H:i:s') : '' }} - show - edit -
no records found
- - Create new -{% endblock %} \ No newline at end of file diff --git a/templates/question/new.html.twig b/templates/question/new.html.twig deleted file mode 100644 index 9039702..0000000 --- a/templates/question/new.html.twig +++ /dev/null @@ -1,11 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}New Question{% endblock %} - -{% block body %} -

Create new Question

- - {{ include('question/_form.html.twig') }} - - back to list -{% endblock %} \ No newline at end of file diff --git a/templates/question/show.html.twig b/templates/question/show.html.twig deleted file mode 100644 index bb6d3a2..0000000 --- a/templates/question/show.html.twig +++ /dev/null @@ -1,30 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Question{% endblock %} - -{% block body %} -

Question

- - - - - - - - - - - - - - - - -
Id{{ question.id }}
Text{{ question.text }}
Date{{ question.date ? question.date|date('Y-m-d H:i:s') : '' }}
- - back to list - - edit - - {{ include('question/_delete_form.html.twig') }} -{% endblock %} \ No newline at end of file diff --git a/templates/response/_delete_form.html.twig b/templates/response/_delete_form.html.twig deleted file mode 100644 index 162e88d..0000000 --- a/templates/response/_delete_form.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -
- - - -
\ No newline at end of file diff --git a/templates/response/_form.html.twig b/templates/response/_form.html.twig deleted file mode 100644 index 92948ad..0000000 --- a/templates/response/_form.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -{{ form_start(form) }} - {{ form_widget(form) }} - -{{ form_end(form) }} \ No newline at end of file diff --git a/templates/response/edit.html.twig b/templates/response/edit.html.twig deleted file mode 100644 index 361f9bb..0000000 --- a/templates/response/edit.html.twig +++ /dev/null @@ -1,13 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Edit Response{% endblock %} - -{% block body %} -

Edit Response

- - {{ include('response/_form.html.twig', {'button_label': 'Update'}) }} - - back to list - - {{ include('response/_delete_form.html.twig') }} -{% endblock %} \ No newline at end of file diff --git a/templates/response/index.html.twig b/templates/response/index.html.twig deleted file mode 100644 index dd086be..0000000 --- a/templates/response/index.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Response index{% endblock %} - -{% block body %} -

Response index

- - - - - - - - - - - {% for response in responses %} - - - - - - {% else %} - - - - {% endfor %} - -
IdTextactions
{{ response.id }}{{ response.text }} - show - edit -
no records found
- - Create new -{% endblock %} \ No newline at end of file diff --git a/templates/response/new.html.twig b/templates/response/new.html.twig deleted file mode 100644 index e4eb105..0000000 --- a/templates/response/new.html.twig +++ /dev/null @@ -1,11 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}New Response{% endblock %} - -{% block body %} -

Create new Response

- - {{ include('response/_form.html.twig') }} - - back to list -{% endblock %} \ No newline at end of file diff --git a/templates/response/show.html.twig b/templates/response/show.html.twig deleted file mode 100644 index b7fa5d3..0000000 --- a/templates/response/show.html.twig +++ /dev/null @@ -1,26 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Response{% endblock %} - -{% block body %} -

Response

- - - - - - - - - - - - -
Id{{ response.id }}
Text{{ response.text }}
- - back to list - - edit - - {{ include('response/_delete_form.html.twig') }} -{% endblock %} \ No newline at end of file