Add a width and height configuration parameter and fix the form theming
so that it works.
This commit is contained in:
parent
421e1827c0
commit
1afeeb8733
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Gregwar\CaptchaBundle\DependencyInjection;
|
||||||
|
|
||||||
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||||
|
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||||
|
|
||||||
|
class Configuration implements ConfigurationInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Generates the configuration tree.
|
||||||
|
* @return TreeBuilder
|
||||||
|
*/
|
||||||
|
public function getConfigTreeBuilder()
|
||||||
|
{
|
||||||
|
$treeBuilder = new TreeBuilder();
|
||||||
|
$rootNode = $treeBuilder->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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,12 +12,19 @@ class GregwarCaptchaExtension extends Extension
|
||||||
{
|
{
|
||||||
public function load(array $configs, ContainerBuilder $container)
|
public function load(array $configs, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
|
|
||||||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||||
$loader->load('services.yml');
|
$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 = $container->getParameter('twig.form.resources');
|
||||||
$resources[] = 'GregwarCaptchaBundle::captcha.html.twig';
|
$container->setParameter('twig.form.resources',array_merge(array('GregwarCaptchaBundle::captcha.html.twig'), $resources));
|
||||||
$container->setParameter('twig.form.resources', $resources);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue