Allow for bool type as config type
This commit is contained in:
parent
da8a1e37ca
commit
cd3c5a0a52
@ -60,10 +60,8 @@ abstract class BaseController extends AbstractController
|
|||||||
switch ($type) {
|
switch ($type) {
|
||||||
case CheckboxType::class:
|
case CheckboxType::class:
|
||||||
return boolval($value);
|
return boolval($value);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return $value;
|
return $value;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
{
|
{
|
||||||
public const TYPE_TEXT = 'text';
|
public const TYPE_TEXT = 'text';
|
||||||
public const TYPE_NUMBER = 'number';
|
public const TYPE_NUMBER = 'number';
|
||||||
|
public const TYPE_BOOL = 'bool';
|
||||||
|
|
||||||
public function getConfigTreeBuilder()
|
public function getConfigTreeBuilder()
|
||||||
{
|
{
|
||||||
@ -24,7 +25,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->children()
|
->children()
|
||||||
->scalarNode('name')->end()
|
->scalarNode('name')->end()
|
||||||
->enumNode('type')
|
->enumNode('type')
|
||||||
->values([self::TYPE_TEXT, self::TYPE_NUMBER])
|
->values([self::TYPE_TEXT, self::TYPE_NUMBER, self::TYPE_BOOL])
|
||||||
->defaultValue(self::TYPE_TEXT)
|
->defaultValue(self::TYPE_TEXT)
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
@ -6,6 +6,7 @@ use Ardent\ParameterBundle\DependencyInjection\Configuration;
|
|||||||
use Ardent\ParameterBundle\Entity\Parameter;
|
use Ardent\ParameterBundle\Entity\Parameter;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
|
||||||
@ -101,6 +102,9 @@ class ParameterService
|
|||||||
case Configuration::TYPE_NUMBER:
|
case Configuration::TYPE_NUMBER:
|
||||||
$class = NumberType::class;
|
$class = NumberType::class;
|
||||||
break;
|
break;
|
||||||
|
case Configuration::TYPE_BOOL:
|
||||||
|
$class = CheckboxType::class;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the group name in front of the parameter name
|
// Add the group name in front of the parameter name
|
||||||
|
Loading…
Reference in New Issue
Block a user