Cleanup config and fix rendering
This commit is contained in:
@ -2,9 +2,12 @@
|
||||
|
||||
namespace Ardent\ParameterBundle\Service;
|
||||
|
||||
use Ardent\ParameterBundle\DependencyInjection\Configuration;
|
||||
use Ardent\ParameterBundle\Entity\Parameter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
class ParameterService
|
||||
{
|
||||
@ -26,12 +29,12 @@ class ParameterService
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->parameter = $parameter;
|
||||
$this->config = $config;
|
||||
$this->config = $this->supplementConfig($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param bool $parse
|
||||
* @param bool $parse
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -80,6 +83,35 @@ class ParameterService
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the types in the config by their classes
|
||||
*
|
||||
* @param $config
|
||||
* @return array
|
||||
*/
|
||||
private function supplementConfig($config)
|
||||
{
|
||||
foreach ($config as $groupName => &$group) {
|
||||
foreach ($group as &$value) {
|
||||
switch ($value['type']) {
|
||||
default:
|
||||
case Configuration::TYPE_TEXT:
|
||||
$class = TextType::class;
|
||||
break;
|
||||
case Configuration::TYPE_NUMBER:
|
||||
$class = NumberType::class;
|
||||
break;
|
||||
}
|
||||
|
||||
$value['name'] = sprintf('%s_%s', $groupName, $value['name']);
|
||||
$value['type'] = $class;
|
||||
unset($value);
|
||||
}
|
||||
unset($group);
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
Reference in New Issue
Block a user