12 Commits

Author SHA1 Message Date
3ccfdf1c93 Merge pull request #200 from adamwojs/fix_deprecated_tree_builder_root_call
Fixed deprecated TreeBuilder::root method call in SF 4
2019-09-23 15:07:46 +02:00
b703ed1a0c Merge pull request #201 from adamwojs/fix_deprecated_spacelesss_tag
Removed deprecated spaceless tag
2019-09-23 15:07:20 +02:00
25de43ac90 Removed deprecated spaceless tag 2019-09-22 13:59:41 +02:00
1b4835eb4d Fixed deprecated TreeBuilder::root method call in SF 4 2019-09-22 13:10:16 +02:00
be1ce45060 Merge pull request #196 from ferdynator/master
Fixes deprecation warnings in Symfony 4.2
2019-08-15 18:04:18 +02:00
0f6cd70920 Fixed deprecation warning 2019-01-23 11:01:56 +01:00
754310f488 Fixed deprecation warning 2019-01-23 11:01:17 +01:00
c2d5468556 Merge pull request #172 from cengizhancaliskan/master
Support of multiple instance
2018-11-20 11:41:34 +01:00
980afdc10a Merge pull request #187 from mandalor-development/master
Changed template reference
2018-04-24 11:22:05 +02:00
791128c0fd Changed template reference
According to:
https://symfony.com/doc/current/templating.html#referencing-templates-in-a-bundle

Fixed error:
[critical] Uncaught PHP Exception Twig_Error_Loader: "Unable to find template "GregwarCaptchaBundle::captcha.html.twig" (looked into: /[path]/templates, /[path]/templates, /[path]/vendor/symfony/twig-bridge/Resources/views/Form)." at /[path]/templates/form.html.twig line 17
2018-02-28 15:15:55 +01:00
ba9c0e6166 Change session key for as_url option 2017-03-27 22:32:00 +03:00
25b8840f2a Support of multiple instance 2017-03-19 18:40:34 +03:00
7 changed files with 22 additions and 12 deletions

View File

@ -2,7 +2,7 @@
namespace Gregwar\CaptchaBundle\Controller; namespace Gregwar\CaptchaBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -11,7 +11,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* *
* @author Jeremy Livingston <jeremy.j.livingston@gmail.com> * @author Jeremy Livingston <jeremy.j.livingston@gmail.com>
*/ */
class CaptchaController extends Controller class CaptchaController extends AbstractController
{ {
/** /**
* Action that is used to generate the captcha, save its code, and stream the image * Action that is used to generate the captcha, save its code, and stream the image

View File

@ -14,8 +14,14 @@ class Configuration implements ConfigurationInterface
*/ */
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder(); $treeBuilder = new TreeBuilder('gregwar_captcha');
if (method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
// BC for symfony/config <= 4.1
$rootNode = $treeBuilder->root('gregwar_captcha'); $rootNode = $treeBuilder->root('gregwar_captcha');
}
$rootNode $rootNode
->addDefaultsIfNotSet() ->addDefaultsIfNotSet()
@ -47,6 +53,7 @@ class Configuration implements ConfigurationInterface
->arrayNode('background_images')->prototype('scalar')->end()->end() ->arrayNode('background_images')->prototype('scalar')->end()->end()
->scalarNode('disabled')->defaultValue(false)->end() ->scalarNode('disabled')->defaultValue(false)->end()
->scalarNode('ignore_all_effects')->defaultValue(false)->end() ->scalarNode('ignore_all_effects')->defaultValue(false)->end()
->scalarNode('session_key')->defaultValue('captcha')->end()
->end() ->end()
; ;

View File

@ -34,6 +34,6 @@ class GregwarCaptchaExtension extends Extension
$container->setParameter('gregwar_captcha.config.whitelist_key', $config['whitelist_key']); $container->setParameter('gregwar_captcha.config.whitelist_key', $config['whitelist_key']);
$resources = $container->getParameter('twig.form.resources'); $resources = $container->getParameter('twig.form.resources');
$container->setParameter('twig.form.resources', array_merge(array('GregwarCaptchaBundle::captcha.html.twig'), $resources)); $container->setParameter('twig.form.resources', array_merge(array('@GregwarCaptcha/captcha.html.twig'), $resources));
} }
} }

View File

@ -1,3 +1,3 @@
gregwar_captcha.generate_captcha: gregwar_captcha.generate_captcha:
path: /generate-captcha/{key} path: /generate-captcha/{key}
defaults: { _controller: GregwarCaptchaBundle:Captcha:generateCaptcha } defaults: { _controller: Gregwar\CaptchaBundle\Controller\CaptchaController::generateCaptchaAction }

View File

@ -2,7 +2,7 @@
{% if is_human %} {% if is_human %}
- -
{% else %} {% else %}
{% spaceless %} {% apply spaceless %}
<img class="captcha_image" 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">
@ -14,6 +14,6 @@
<a class="captcha_reload" href="javascript:reload_{{ image_id }}();">{{ 'Renew'|trans({}, 'gregwar_captcha') }}</a> <a class="captcha_reload" href="javascript:reload_{{ image_id }}();">{{ 'Renew'|trans({}, 'gregwar_captcha') }}</a>
{% endif %} {% endif %}
{{ form_widget(form) }} {{ form_widget(form) }}
{% endspaceless %} {% endapply %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -22,6 +22,8 @@ use Gregwar\CaptchaBundle\Generator\CaptchaGenerator;
*/ */
class CaptchaType extends AbstractType class CaptchaType extends AbstractType
{ {
const SESSION_KEY_PREFIX = '_captcha_';
/** /**
* @var SessionInterface * @var SessionInterface
*/ */
@ -65,7 +67,7 @@ class CaptchaType extends AbstractType
$validator = new CaptchaValidator( $validator = new CaptchaValidator(
$this->translator, $this->translator,
$this->session, $this->session,
sprintf('gcb_%s', $builder->getForm()->getName()), sprintf('%s%s', self::SESSION_KEY_PREFIX, $options['session_key']),
$options['invalid_message'], $options['invalid_message'],
$options['bypass_code'], $options['bypass_code'],
$options['humanity'] $options['humanity']
@ -83,7 +85,7 @@ class CaptchaType extends AbstractType
throw new \InvalidArgumentException('GregwarCaptcha: The reload option cannot be set without as_url, see the README for more information'); throw new \InvalidArgumentException('GregwarCaptcha: The reload option cannot be set without as_url, see the README for more information');
} }
$sessionKey = sprintf('gcb_%s', $form->getName()); $sessionKey = sprintf('%s%s', self::SESSION_KEY_PREFIX, $options['session_key']);
$isHuman = false; $isHuman = false;
if ($options['humanity'] > 0) { if ($options['humanity'] > 0) {

View File

@ -20,7 +20,8 @@
"php": ">=5.3.9", "php": ">=5.3.9",
"gregwar/captcha": "~1.1", "gregwar/captcha": "~1.1",
"symfony/framework-bundle": "~2.8|~3.0|~4.0", "symfony/framework-bundle": "~2.8|~3.0|~4.0",
"symfony/form": "~2.8|~3.0|~4.0" "symfony/form": "~2.8|~3.0|~4.0",
"twig/twig": "^1.40|^2.9"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {