Add config and controller to use the config
This commit is contained in:
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Ardent\ParameterBundle\DependencyInjection;
|
||||
|
||||
use Ardent\ParameterBundle\Entity\Parameter;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\Extension;
|
||||
@ -14,8 +13,14 @@ class ArdentParameterExtension extends Extension
|
||||
{
|
||||
$loader = new YamlFileLoader(
|
||||
$container,
|
||||
new FileLocator(__DIR__.'/../Resources/config')
|
||||
new FileLocator(dirname(__DIR__).'/Resources/config')
|
||||
);
|
||||
$loader->load('services.yaml');
|
||||
|
||||
$configuration = new Configuration();
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$def = $container->findDefinition('ardent.parameter');
|
||||
$def->setArgument('$config', $config['parameters']);
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,35 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public const TYPE_TEXT = 'text';
|
||||
public const TYPE_NUMBER = 'number';
|
||||
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('parameter_bundle');
|
||||
$treeBuilder = new TreeBuilder('ardent_parameter');
|
||||
|
||||
$treeBuilder->getRootNode()
|
||||
->children()
|
||||
->end();
|
||||
->arrayNode('parameters')
|
||||
->arrayPrototype()
|
||||
->children()
|
||||
->scalarNode('group')->defaultValue('misc')->end()
|
||||
->arrayNode('values')
|
||||
->arrayPrototype()
|
||||
->children()
|
||||
->scalarNode('name')->end()
|
||||
->enumNode('type')
|
||||
->values([self::TYPE_TEXT, self::TYPE_NUMBER])
|
||||
->defaultValue(self::TYPE_TEXT)
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end();
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user