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-07-27 01:02:18 +02:00
public function parameters($category,
ParameterService $param,
Request $request)
{
2020-07-27 01:02:18 +02:00
$configs = $param->getConfig();
// Handle all special cases for the name
/*if ('list' === $name) { // List all the categories
$routes = [];
foreach ($configs as $key => $config) {
$routes[] = ['route' => 'parameters', 'params' => ['name' => $key], 'title' => $key];
}
return $this->render('list.routes.twig', ['routes' => $routes]);
2020-07-27 01:02:18 +02:00
} else*/if ('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]);
}
}
}