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\Definition;
|
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
|
|
|
use Symfony\Component\Config\FileLocator;
|
|
|
|
|
|
|
|
class GregwarCaptchaExtension extends Extension
|
|
|
|
{
|
|
|
|
public function load(array $configs, ContainerBuilder $container)
|
|
|
|
{
|
2011-09-08 17:02:40 +02:00
|
|
|
|
2011-08-25 22:50:59 +02:00
|
|
|
$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-09-09 20:02:47 +02:00
|
|
|
$container->setParameter('gregwar_captcha.length', $config['length']);
|
|
|
|
$container->setParameter('gregwar_captcha.height', $config['height']);
|
|
|
|
$container->setParameter('gregwar_captcha.width', $config['width']);
|
2011-11-09 14:43:25 +01:00
|
|
|
$container->setParameter('gregwar_captcha.as_file', $config['as_file']);
|
|
|
|
$container->setParameter('gregwar_captcha.image_folder', $config['image_folder']);
|
|
|
|
$container->setParameter('gregwar_captcha.web_path', $config['web_path']);
|
2011-11-09 17:58:53 +01:00
|
|
|
$container->setParameter('gregwar_captcha.gc_freq', $config['gc_freq']);
|
|
|
|
$container->setParameter('gregwar_captcha.expiration', $config['expiration']);
|
2011-09-09 20:02:47 +02:00
|
|
|
|
2011-08-25 22:50:59 +02:00
|
|
|
$resources = $container->getParameter('twig.form.resources');
|
2011-09-08 17:02:40 +02:00
|
|
|
$container->setParameter('twig.form.resources',array_merge(array('GregwarCaptchaBundle::captcha.html.twig'), $resources));
|
2011-11-09 14:43:25 +01:00
|
|
|
|
2011-08-25 22:50:59 +02:00
|
|
|
}
|
2011-11-09 14:43:25 +01:00
|
|
|
|
2011-08-25 22:50:59 +02:00
|
|
|
}
|
|
|
|
|