From be90f19f3ad307c1d9490820e41c39fb25e2ce3d Mon Sep 17 00:00:00 2001 From: Gregwar Date: Mon, 22 Apr 2013 00:32:40 +0200 Subject: [PATCH] Adding backgroundColor option (fixes #55) --- DependencyInjection/Configuration.php | 1 + Generator/CaptchaGenerator.php | 9 +++++++++ composer.json | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 30f65cb..ec86135 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -39,6 +39,7 @@ class Configuration implements ConfigurationInterface ->scalarNode('whitelist_key')->defaultValue('captcha_whitelist_key')->end() ->scalarNode('humanity')->defaultValue(0)->end() ->scalarNode('distortion')->defaultValue(true)->end() + ->arrayNode('backgroundColor')->prototype('scalar')->end() ->end() ; diff --git a/Generator/CaptchaGenerator.php b/Generator/CaptchaGenerator.php index bd99ca8..bc129ce 100644 --- a/Generator/CaptchaGenerator.php +++ b/Generator/CaptchaGenerator.php @@ -95,6 +95,15 @@ class CaptchaGenerator { $this->builder->setDistortion($options['distortion']); + if ($options['backgroundColor'] != array()) { + if (count($options['backgroundColor'])!=3) { + throw new \RuntimeException('backgroundColor should be an array of r, g and b'); + } + + $color = $options['backgroundColor']; + $this->builder->setBackgroundColor($color[0], $color[1], $color[2]); + } + $fingerprint = isset($options['fingerprint']) ? $options['fingerprint'] : null; $content = $this->builder->build( diff --git a/composer.json b/composer.json index 6b01892..2e2b0ce 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ], "require": { "php": ">=5.3.0", - "gregwar/captcha": "v1.0.1" + "gregwar/captcha": "v1.0.3" }, "autoload": { "psr-0": {