From 3486274c18037cf5582902e0f9ff5f2dc0e3b76b Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Fri, 17 Sep 2021 12:52:04 +0200 Subject: [PATCH] Remove compiler pass in favour of the nyholm_psr7 recipe --- README.md | 8 +--- .../SymfonyHttpClientCompilerPass.php | 41 ------------------- src/FluxSESyliusHCaptchaPlugin.php | 11 ----- .../packages/meteo_concept_hcaptcha.yaml | 9 +--- .../config/packages/nyholm_psr7.yaml | 21 ++++++++++ 5 files changed, 25 insertions(+), 65 deletions(-) delete mode 100644 src/DependencyInjection/CompilerPass/SymfonyHttpClientCompilerPass.php create mode 100644 tests/Application/config/packages/nyholm_psr7.yaml diff --git a/README.md b/README.md index 9b606cb..9d44344 100644 --- a/README.md +++ b/README.md @@ -40,14 +40,10 @@ Add or modify the `meteo-concept/hcaptcha-bundle` configuration : ```yaml # config/packages/meteo_concept_hcaptcha.yaml -parameters: - hcaptcha_site_key: '%env(resolve:HCAPTCHA_SITE_KEY)%' - hcaptcha_secret: '%env(resolve:HCAPTCHA_SECRET)%' - meteo_concept_h_captcha: hcaptcha: - site_key: '%hcaptcha_site_key%' - secret: '%hcaptcha_secret%' + site_key: '%env(resolve:HCAPTCHA_SITE_KEY)%' + secret: '%env(resolve:HCAPTCHA_SECRET)%' validation: 'strict' ``` diff --git a/src/DependencyInjection/CompilerPass/SymfonyHttpClientCompilerPass.php b/src/DependencyInjection/CompilerPass/SymfonyHttpClientCompilerPass.php deleted file mode 100644 index 9b85e44..0000000 --- a/src/DependencyInjection/CompilerPass/SymfonyHttpClientCompilerPass.php +++ /dev/null @@ -1,41 +0,0 @@ -has(ClientInterface::class)) { - $container->setDefinition( - ClientInterface::class, - new Definition(Psr18Client::class) - ); - } - - if (false === $container->has(RequestFactoryInterface::class)) { - $container->setDefinition( - RequestFactoryInterface::class, - new Definition(Psr17Factory::class) - ); - } - - if (false === $container->has(StreamFactoryInterface::class)) { - $container->setDefinition( - StreamFactoryInterface::class, - new Definition(Psr17Factory::class) - ); - } - } -} diff --git a/src/FluxSESyliusHCaptchaPlugin.php b/src/FluxSESyliusHCaptchaPlugin.php index e55a3ef..aa30a9d 100644 --- a/src/FluxSESyliusHCaptchaPlugin.php +++ b/src/FluxSESyliusHCaptchaPlugin.php @@ -4,21 +4,10 @@ namespace FluxSE\SyliusHCaptchaPlugin; -use FluxSE\SyliusHCaptchaPlugin\DependencyInjection\CompilerPass\SymfonyHttpClientCompilerPass; use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; final class FluxSESyliusHCaptchaPlugin extends Bundle { use SyliusPluginTrait; - - public function build(ContainerBuilder $container): void - { - parent::build($container); - - $container - ->addCompilerPass(new SymfonyHttpClientCompilerPass()) - ; - } } diff --git a/tests/Application/config/packages/meteo_concept_hcaptcha.yaml b/tests/Application/config/packages/meteo_concept_hcaptcha.yaml index 21afb15..a9ffb84 100644 --- a/tests/Application/config/packages/meteo_concept_hcaptcha.yaml +++ b/tests/Application/config/packages/meteo_concept_hcaptcha.yaml @@ -1,9 +1,4 @@ -parameters: - hcaptcha_site_key: '%env(resolve:HCAPTCHA_SITE_KEY)%' - hcaptcha_secret: '%env(resolve:HCAPTCHA_SECRET)%' - meteo_concept_h_captcha: hcaptcha: - site_key: '%hcaptcha_site_key%' - secret: '%hcaptcha_secret%' - validation: 'strict' \ No newline at end of file + site_key: '%env(resolve:HCAPTCHA_SITE_KEY)%' + secret: '%env(resolve:HCAPTCHA_SECRET)%' \ No newline at end of file diff --git a/tests/Application/config/packages/nyholm_psr7.yaml b/tests/Application/config/packages/nyholm_psr7.yaml new file mode 100644 index 0000000..f135723 --- /dev/null +++ b/tests/Application/config/packages/nyholm_psr7.yaml @@ -0,0 +1,21 @@ +services: + # Register nyholm/psr7 services for autowiring with PSR-17 (HTTP factories) + Psr\Http\Message\RequestFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\ResponseFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\ServerRequestFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\StreamFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\UploadedFileFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\UriFactoryInterface: '@nyholm.psr7.psr17_factory' + + # Register nyholm/psr7 services for autowiring with HTTPlug factories + Http\Message\MessageFactory: '@nyholm.psr7.httplug_factory' + Http\Message\RequestFactory: '@nyholm.psr7.httplug_factory' + Http\Message\ResponseFactory: '@nyholm.psr7.httplug_factory' + Http\Message\StreamFactory: '@nyholm.psr7.httplug_factory' + Http\Message\UriFactory: '@nyholm.psr7.httplug_factory' + + nyholm.psr7.psr17_factory: + class: Nyholm\Psr7\Factory\Psr17Factory + + nyholm.psr7.httplug_factory: + class: Nyholm\Psr7\Factory\HttplugFactory