2011-08-25 22:50:59 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Gregwar\CaptchaBundle\DependencyInjection;
|
|
|
|
|
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
|
|
|
use Symfony\Component\Config\FileLocator;
|
|
|
|
|
2012-11-14 04:33:36 +01:00
|
|
|
/**
|
|
|
|
* Extension used to load the configuration, set parameters, and initialize the captcha view
|
|
|
|
*
|
|
|
|
* @author Gregwar <g.passault@gmail.com>
|
|
|
|
*/
|
2011-08-25 22:50:59 +02:00
|
|
|
class GregwarCaptchaExtension extends Extension
|
|
|
|
{
|
2012-11-14 04:33:36 +01:00
|
|
|
/**
|
|
|
|
* @param array $configs
|
2015-05-13 03:12:49 +02:00
|
|
|
* @param ContainerBuilder $container
|
2012-11-14 04:33:36 +01:00
|
|
|
*/
|
2011-08-25 22:50:59 +02:00
|
|
|
public function load(array $configs, ContainerBuilder $container)
|
|
|
|
{
|
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
|
|
|
$loader->load('services.yml');
|
|
|
|
|
2011-09-08 17:02:40 +02:00
|
|
|
$configuration = new Configuration();
|
|
|
|
$config = $this->processConfiguration($configuration, $configs);
|
|
|
|
|
2011-12-02 18:36:34 +01:00
|
|
|
$container->setParameter('gregwar_captcha.config', $config);
|
2012-11-14 04:33:36 +01:00
|
|
|
$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']);
|
2012-12-04 11:33:54 +01:00
|
|
|
$container->setParameter('gregwar_captcha.config.whitelist_key', $config['whitelist_key']);
|
2011-09-09 20:02:47 +02:00
|
|
|
|
2011-08-25 22:50:59 +02:00
|
|
|
$resources = $container->getParameter('twig.form.resources');
|
2018-02-28 15:15:55 +01:00
|
|
|
$container->setParameter('twig.form.resources', array_merge(array('@GregwarCaptcha/captcha.html.twig'), $resources));
|
2011-08-25 22:50:59 +02:00
|
|
|
}
|
|
|
|
}
|