Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="beelab_recaptcha2.google_recaptcha.request_method" class="%beelab_recaptcha2.request_method%" />
<service id="beelab_recaptcha2.google_recaptcha" class="ReCaptcha\ReCaptcha">
<argument>%beelab_recaptcha2.secret%</argument>
<argument type="service" id="beelab_recaptcha2.google_recaptcha.request_method" />
<argument /><!-- replaced by Configuration -->
</service>
<service id="Beelab\Recaptcha2Bundle\Recaptcha\SymfonyClientRequestMethod" public="false">
<call method="setClient">
Expand Down
2 changes: 2 additions & 0 deletions src/BeelabRecaptcha2Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Beelab\Recaptcha2Bundle;

use Beelab\Recaptcha2Bundle\DependencyInjection\Compiler\RequestMethodPass;
use Beelab\Recaptcha2Bundle\DependencyInjection\Compiler\TwigFormPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
Expand All @@ -12,6 +13,7 @@ public function build(ContainerBuilder $container): void
{
parent::build($container);
$container->addCompilerPass(new TwigFormPass());
$container->addCompilerPass(new RequestMethodPass());
}

public function getPath(): string
Expand Down
17 changes: 17 additions & 0 deletions src/DependencyInjection/Compiler/RequestMethodPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Beelab\Recaptcha2Bundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

final class RequestMethodPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
$service = $container->getDefinition('beelab_recaptcha2.google_recaptcha');
$methodClass = $container->getParameter('beelab_recaptcha2.request_method');
$methodService = $container->getDefinition($methodClass);
$service->replaceArgument(1, $methodService);
}
}