Added captcha image width and height as a configuration setting.
This commit is contained in:
@ -2,13 +2,14 @@
|
||||
|
||||
namespace Gregwar\CaptchaBundle\Type;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\HttpFoundation\Session;
|
||||
|
||||
use Gregwar\CaptchaBundle\Validator\CaptchaValidator;
|
||||
use Gregwar\CaptchaBundle\Generator\CaptchaGenerator;
|
||||
@ -20,13 +21,33 @@ use Gregwar\CaptchaBundle\Generator\CaptchaGenerator;
|
||||
*/
|
||||
class CaptchaType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* The image height
|
||||
* @var integer
|
||||
*/
|
||||
protected $height;
|
||||
|
||||
/**
|
||||
* The image width
|
||||
* @var integer
|
||||
*/
|
||||
protected $width;
|
||||
|
||||
/**
|
||||
* The session
|
||||
* @var Symfony\Component\HttpFoundation\Session
|
||||
*/
|
||||
protected $session;
|
||||
|
||||
private $key = 'captcha';
|
||||
|
||||
protected $session;
|
||||
|
||||
public function __construct(Session $session)
|
||||
public function __construct(Session $session, ContainerInterface $container)
|
||||
{
|
||||
$this->session = $session;
|
||||
$this->height = $container->getParameter('gregwar_captcha.image.height');
|
||||
$this->width = $container->getParameter('gregwar_captcha.image.width');
|
||||
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilder $builder, array $options)
|
||||
@ -40,7 +61,9 @@ class CaptchaType extends AbstractType
|
||||
{
|
||||
$generator = new CaptchaGenerator($this->generateCaptchaValue());
|
||||
|
||||
$view->set('captcha_code', $generator->getCode());
|
||||
$view->set('captcha_code', $generator->getCode($this->width, $this->height));
|
||||
$view->set('captcha_width', $this->width);
|
||||
$view->set('captcha_height', $this->height);
|
||||
}
|
||||
|
||||
public function getParent(array $options)
|
||||
|
Reference in New Issue
Block a user