From d20f7401c1136fc331af3ff7fcafabb585ed130c Mon Sep 17 00:00:00 2001 From: ardent Date: Fri, 23 Oct 2020 23:39:45 +0200 Subject: [PATCH] Add categories overview --- Controller/ParameterController.php | 14 +++++++------- Resources/views/categories.html.twig | 9 +++++++++ Resources/views/form.extra.html.twig | 1 + Resources/views/form.html.twig | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 Resources/views/categories.html.twig diff --git a/Controller/ParameterController.php b/Controller/ParameterController.php index b6662d9..19b5d4e 100644 --- a/Controller/ParameterController.php +++ b/Controller/ParameterController.php @@ -13,21 +13,21 @@ class ParameterController extends BaseController /** * @Route("/{category}", name="parameter_bundle_parameters") */ - public function parameters($category, + public function parameters($category = 'categories', ParameterService $param, Request $request) { $configs = $param->getConfig(); // Handle all special cases for the name - /*if ('list' === $name) { // List all the categories - $routes = []; + if ('categories' === $category) { // List all the categories + $categories = []; foreach ($configs as $key => $config) { - $routes[] = ['route' => 'parameters', 'params' => ['name' => $key], 'title' => $key]; + $categories[] = $key; } - - return $this->render('list.routes.twig', ['routes' => $routes]); - } else*/if ('all' === $category) { // Show all parameters from all categories + $categories[] = 'all'; + return $this->render('@ArdentParameter/categories.html.twig', ['categories' => $categories]); + } elseif ('all' === $category) { // Show all parameters from all categories $allConfigs = []; foreach ($configs as $config) { $allConfigs = array_merge($allConfigs, $config); diff --git a/Resources/views/categories.html.twig b/Resources/views/categories.html.twig new file mode 100644 index 0000000..53ed45c --- /dev/null +++ b/Resources/views/categories.html.twig @@ -0,0 +1,9 @@ +{% extends '@ArdentParameter/layout.html.twig' %} + + +{% block par_user_content %} +

Parameter categories


+ {% for category in categories %} + {{ category }}

+ {% endfor %} +{% endblock %} \ No newline at end of file diff --git a/Resources/views/form.extra.html.twig b/Resources/views/form.extra.html.twig index e69de29..fa6b984 100644 --- a/Resources/views/form.extra.html.twig +++ b/Resources/views/form.extra.html.twig @@ -0,0 +1 @@ +{# Add extra content on the bottom of the form #} \ No newline at end of file diff --git a/Resources/views/form.html.twig b/Resources/views/form.html.twig index 83d0ae3..e32a2eb 100644 --- a/Resources/views/form.html.twig +++ b/Resources/views/form.html.twig @@ -1,8 +1,8 @@ {% extends '@ArdentParameter/layout.html.twig' %} - {% block par_user_content %} + Back

{{ form(parameter_form) }} {% include '@ArdentParameter/form.extra.html.twig' %} {% endblock %} \ No newline at end of file