2020-07-27 00:26:57 +02:00
|
|
|
<?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-07-27 00:26:57 +02:00
|
|
|
*/
|
2020-10-23 23:39:45 +02:00
|
|
|
public function parameters($category = 'categories',
|
2020-07-27 00:26:57 +02:00
|
|
|
ParameterService $param,
|
|
|
|
Request $request)
|
|
|
|
{
|
2020-07-27 01:02:18 +02:00
|
|
|
$configs = $param->getConfig();
|
2020-07-27 00:26:57 +02:00
|
|
|
|
|
|
|
// Handle all special cases for the name
|
2020-10-23 23:39:45 +02:00
|
|
|
if ('categories' === $category) { // List all the categories
|
|
|
|
$categories = [];
|
2020-07-27 00:26:57 +02:00
|
|
|
foreach ($configs as $key => $config) {
|
2020-10-23 23:39:45 +02:00
|
|
|
$categories[] = $key;
|
2020-07-27 00:26:57 +02:00
|
|
|
}
|
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
|
2020-07-27 00:26:57 +02:00
|
|
|
$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]);
|
2020-07-27 00:26:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|