ArdentParameterBundle/Controller/ParameterController.php

41 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace Ardent\ParameterBundle\Controller;
use Ardent\ParameterBundle\Service\ParameterService;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class ParameterController extends BaseController
{
/**
2020-07-27 01:02:18 +02:00
* @Route("/{category}", name="parameter_bundle_parameters")
*/
2020-10-23 23:39:45 +02:00
public function parameters($category = 'categories',
ParameterService $param,
Request $request)
{
2020-07-27 01:02:18 +02:00
$configs = $param->getConfig();
// Handle all special cases for the name
2020-10-23 23:39:45 +02:00
if ('categories' === $category) { // List all the categories
$categories = [];
foreach ($configs as $key => $config) {
2020-10-23 23:39:45 +02:00
$categories[] = $key;
}
2020-10-23 23:39:45 +02:00
$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);
}
return parent::baseIndex($param, $request, $allConfigs);
} else { // Show the parameters from one category
2020-07-27 01:02:18 +02:00
return parent::baseIndex($param, $request, $configs[$category]);
}
}
}