diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php new file mode 100644 index 0000000..5b4324b --- /dev/null +++ b/DependencyInjection/Configuration.php @@ -0,0 +1,33 @@ +root('gregwar_captcha', 'array'); + + $rootNode + ->children() + ->arrayNode('image') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('width')->defaultValue(120)->end() + ->scalarNode('height')->defaultValue(40)->end() + ->end() + ->end() + ->end() + ; + return $treeBuilder; + } +} + diff --git a/DependencyInjection/GregwarCaptchaExtension.php b/DependencyInjection/GregwarCaptchaExtension.php index 5292533..d1769c4 100755 --- a/DependencyInjection/GregwarCaptchaExtension.php +++ b/DependencyInjection/GregwarCaptchaExtension.php @@ -12,12 +12,19 @@ class GregwarCaptchaExtension extends Extension { public function load(array $configs, ContainerBuilder $container) { + $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); + $configuration = new Configuration(); + $config = $this->processConfiguration($configuration, $configs); + + $container->setParameter('gregwar_captcha.image.height', $config['image']['height']); + $container->setParameter('gregwar_captcha.image.width', $config['image']['width']); $resources = $container->getParameter('twig.form.resources'); - $resources[] = 'GregwarCaptchaBundle::captcha.html.twig'; - $container->setParameter('twig.form.resources', $resources); + $container->setParameter('twig.form.resources',array_merge(array('GregwarCaptchaBundle::captcha.html.twig'), $resources)); + } + }