Merge remote-tracking branch 'remotes/jeremy/urlgeneration'
Conflicts: DependencyInjection/GregwarCaptchaExtension.php
This commit is contained in:
@ -9,12 +9,13 @@ class Configuration implements ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* Generates the configuration tree.
|
||||
*
|
||||
* @return TreeBuilder
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('gregwar_captcha', 'array');
|
||||
$rootNode = $treeBuilder->root('gregwar_captcha');
|
||||
|
||||
$rootNode
|
||||
->addDefaultsIfNotSet()
|
||||
@ -26,6 +27,7 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('keep_value')->defaultValue(true)->end()
|
||||
->scalarNode('charset')->defaultValue('abcdefhjkmnprstuvwxyz23456789')->end()
|
||||
->scalarNode('as_file')->defaultValue(false)->end()
|
||||
->scalarNode('as_url')->defaultValue(false)->end()
|
||||
->scalarNode('image_folder')->defaultValue('captcha')->end()
|
||||
->scalarNode('web_path')->defaultValue('%kernel.root_dir%/../web')->end()
|
||||
->scalarNode('gc_freq')->defaultValue(100)->end()
|
||||
@ -33,8 +35,10 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('quality')->defaultValue(15)->end()
|
||||
->scalarNode('invalid_message')->defaultValue('Bad code value')->end()
|
||||
->scalarNode('bypass_code')->defaultValue(null)->end()
|
||||
->arrayNode('valid_keys')->defaultValue(array('captcha'))->prototype('scalar')->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,20 @@ namespace Gregwar\CaptchaBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
/**
|
||||
* Extension used to load the configuration, set parameters, and initialize the captcha view
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
*/
|
||||
class GregwarCaptchaExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* @param array $configs
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
@ -19,6 +27,10 @@ class GregwarCaptchaExtension extends Extension
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$container->setParameter('gregwar_captcha.config', $config);
|
||||
$container->setParameter('gregwar_captcha.config.image_folder', $config['image_folder']);
|
||||
$container->setParameter('gregwar_captcha.config.web_path', $config['web_path']);
|
||||
$container->setParameter('gregwar_captcha.config.gc_freq', $config['gc_freq']);
|
||||
$container->setParameter('gregwar_captcha.config.expiration', $config['expiration']);
|
||||
|
||||
$resources = $container->getParameter('twig.form.resources');
|
||||
$container->setParameter('twig.form.resources', array_merge(array('GregwarCaptchaBundle::captcha.html.twig'), $resources));
|
||||
|
Reference in New Issue
Block a user