Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
f6c45045f0 | |||
f95a951b26 | |||
e1ed228b8b | |||
0b3495a081 | |||
53c25b2e9a | |||
fcf8c4fd01 | |||
e91cb1a3b7 | |||
f06ff4d2c2 | |||
ef281889ab |
@ -4,6 +4,8 @@ Gregwar's CaptchaBundle
|
|||||||
The `GregwarCaptchaBundle` adds support for a captcha form type for the
|
The `GregwarCaptchaBundle` adds support for a captcha form type for the
|
||||||
Symfony form component.
|
Symfony form component.
|
||||||
|
|
||||||
|
It uses [gregwar/captcha](https://github.com/Gregwar/Captcha) as captcha generator, which is a separate standalone library that can be used for none-symfony projects.
|
||||||
|
|
||||||
Compatibility with Symfony
|
Compatibility with Symfony
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
gregwar_captcha.generate_captcha:
|
gregwar_captcha.generate_captcha:
|
||||||
pattern: /generate-captcha/{key}
|
path: /generate-captcha/{key}
|
||||||
defaults: { _controller: GregwarCaptchaBundle:Captcha:generateCaptcha }
|
defaults: { _controller: GregwarCaptchaBundle:Captcha:generateCaptcha }
|
@ -7,17 +7,17 @@ parameters:
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
captcha.type:
|
captcha.type:
|
||||||
class: %gregwar_captcha.captcha_type.class%
|
class: '%gregwar_captcha.captcha_type.class%'
|
||||||
arguments:
|
arguments:
|
||||||
- '@session'
|
- '@session'
|
||||||
- '@gregwar_captcha.generator'
|
- '@gregwar_captcha.generator'
|
||||||
- '@translator'
|
- '@translator'
|
||||||
- %gregwar_captcha.config%
|
- '%gregwar_captcha.config%'
|
||||||
tags:
|
tags:
|
||||||
- { name: form.type, alias: captcha }
|
- { name: form.type, alias: captcha }
|
||||||
|
|
||||||
gregwar_captcha.generator:
|
gregwar_captcha.generator:
|
||||||
class: %gregwar_captcha.captcha_generator.class%
|
class: '%gregwar_captcha.captcha_generator.class%'
|
||||||
arguments:
|
arguments:
|
||||||
- '@router'
|
- '@router'
|
||||||
- '@gregwar_captcha.captcha_builder'
|
- '@gregwar_captcha.captcha_builder'
|
||||||
@ -25,15 +25,15 @@ services:
|
|||||||
- '@gregwar_captcha.image_file_handler'
|
- '@gregwar_captcha.image_file_handler'
|
||||||
|
|
||||||
gregwar_captcha.image_file_handler:
|
gregwar_captcha.image_file_handler:
|
||||||
class: %gregwar_captcha.image_file_handler.class%
|
class: '%gregwar_captcha.image_file_handler.class%'
|
||||||
arguments:
|
arguments:
|
||||||
- %gregwar_captcha.config.image_folder%
|
- '%gregwar_captcha.config.image_folder%'
|
||||||
- %gregwar_captcha.config.web_path%
|
- '%gregwar_captcha.config.web_path%'
|
||||||
- %gregwar_captcha.config.gc_freq%
|
- '%gregwar_captcha.config.gc_freq%'
|
||||||
- %gregwar_captcha.config.expiration%
|
- '%gregwar_captcha.config.expiration%'
|
||||||
|
|
||||||
gregwar_captcha.captcha_builder:
|
gregwar_captcha.captcha_builder:
|
||||||
class: %gregwar_captcha.captcha_builder.class%
|
class: '%gregwar_captcha.captcha_builder.class%'
|
||||||
|
|
||||||
gregwar_captcha.phrase_builder:
|
gregwar_captcha.phrase_builder:
|
||||||
class: %gregwar_captcha.phrase_builder.class%
|
class: '%gregwar_captcha.phrase_builder.class%'
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
-
|
-
|
||||||
{% else %}
|
{% else %}
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
<img id="{{ image_id }}" src="{{ captcha_code }}" alt="" title="captcha" width="{{ captcha_width }}" height="{{ captcha_height }}" />
|
<img class="captcha_image" id="{{ image_id }}" src="{{ captcha_code }}" alt="" title="captcha" width="{{ captcha_width }}" height="{{ captcha_height }}" />
|
||||||
{% if reload %}
|
{% if reload %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function reload_{{ image_id }}() {
|
function reload_{{ image_id }}() {
|
||||||
|
@ -143,7 +143,7 @@ class CaptchaType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
// Not using ::class to support Symfony 2.8 w/ php<5.5
|
// Not using ::class to support Symfony 2.8 w/ php>=5.3.9
|
||||||
return 'Symfony\Component\Form\Extension\Core\Type\TextType';
|
return 'Symfony\Component\Form\Extension\Core\Type\TextType';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +151,14 @@ class CaptchaType extends AbstractType
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getBlockPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'captcha';
|
return 'captcha';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user