diff --git a/DependencyInjection/GregwarCaptchaExtension.php b/DependencyInjection/GregwarCaptchaExtension.php index 05ec528..72f61f8 100755 --- a/DependencyInjection/GregwarCaptchaExtension.php +++ b/DependencyInjection/GregwarCaptchaExtension.php @@ -19,14 +19,7 @@ class GregwarCaptchaExtension extends Extension $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $container->setParameter('gregwar_captcha.length', $config['length']); - $container->setParameter('gregwar_captcha.height', $config['height']); - $container->setParameter('gregwar_captcha.width', $config['width']); - $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']); - $container->setParameter('gregwar_captcha.gc_freq', $config['gc_freq']); - $container->setParameter('gregwar_captcha.expiration', $config['expiration']); + $container->setParameter('gregwar_captcha.config', $config); $resources = $container->getParameter('twig.form.resources'); $container->setParameter('twig.form.resources',array_merge(array('GregwarCaptchaBundle::captcha.html.twig'), $resources)); diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 990e47b..9f91571 100755 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -3,6 +3,6 @@ services: # captcha type captcha.type: class: Gregwar\CaptchaBundle\Type\CaptchaType - arguments: [ "@session", %gregwar_captcha.width%, %gregwar_captcha.height%, %gregwar_captcha.length%, %gregwar_captcha.as_file%, %gregwar_captcha.image_folder%, %gregwar_captcha.web_path%, %gregwar_captcha.gc_freq%, %gregwar_captcha.expiration% ] + arguments: [ "@session", %gregwar_captcha.config% ] tags: - { name: form.type, alias: captcha } diff --git a/Type/CaptchaType.php b/Type/CaptchaType.php index 0bea461..eb9a8f8 100755 --- a/Type/CaptchaType.php +++ b/Type/CaptchaType.php @@ -76,20 +76,25 @@ class CaptchaType extends AbstractType */ protected $session; + /** + * Session key + * @var String + */ private $key = 'captcha'; - public function __construct(Session $session, $width, $height, $length, $asFile, $imageFolder, $webPath, $gcFreq, $expiration) + public function __construct(Session $session, $config) { $this->session = $session; - $this->width = $width; - $this->height = $height; - $this->length = $length; - $this->asFile = $asFile; - $this->imageFolder = $imageFolder; - $this->webPath = $webPath; - $this->gcFreq = $gcFreq; - $this->expiration = $expiration; + + $this->width = $config['width']; + $this->height = $config['height']; + $this->length = $config['length']; + $this->asFile = $config['as_file']; + $this->imageFolder = $config['image_folder']; + $this->webPath = $config['web_path']; + $this->gcFreq = $config['gc_freq']; + $this->expiration = $config['expiration']; } public function buildForm(FormBuilder $builder, array $options)