Skip to content

Commit a1022ae

Browse files
committed
Switch the service configuration to PHP now that the XML format is deprecated
1 parent 690f56c commit a1022ae

File tree

3 files changed

+58
-66
lines changed

3 files changed

+58
-66
lines changed

DependencyInjection/MeteoConceptHCaptchaExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Symfony\Component\DependencyInjection\ContainerBuilder;
66
use Symfony\Component\DependencyInjection\Extension\Extension;
77
use Symfony\Component\Config\FileLocator;
8-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
8+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
99

1010
/**
1111
* The bundle extension class, used to load the configuration
@@ -14,8 +14,8 @@ class MeteoConceptHCaptchaExtension extends Extension
1414
{
1515
public function load(array $configs, ContainerBuilder $container): void
1616
{
17-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
18-
$loader->load('services.xml');
17+
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
18+
$loader->load('services.php');
1919

2020
$configuration = new Configuration();
2121
$config = $this->processConfiguration($configuration, $configs);

Resources/config/services.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
4+
5+
return static function (ContainerConfigurator $container) {
6+
$services = $container->services();
7+
$parameters = $container->parameters();
8+
9+
$services->defaults()
10+
->private()
11+
->autowire(false)
12+
->autoconfigure(false);
13+
14+
$services->set('meteo_concept_h_captcha.captcha_verifier', \MeteoConcept\HCaptchaBundle\Service\HCaptchaVerifier::class)
15+
->public()
16+
->args([
17+
service(\Psr\Http\Client\ClientInterface::class),
18+
service(\Psr\Http\Message\RequestFactoryInterface::class),
19+
service(\Psr\Http\Message\StreamFactoryInterface::class),
20+
'',
21+
service('logger')->nullOnInvalid(),
22+
]);
23+
24+
$services->alias(\MeteoConcept\HCaptchaBundle\Service\HCaptchaVerifier::class, 'meteo_concept_h_captcha.captcha_verifier')
25+
->private();
26+
27+
$services->set('meteo_concept_h_captcha.captcha_validator', \MeteoConcept\HCaptchaBundle\Validator\Constraints\IsValidCaptchaValidator::class)
28+
->public()
29+
->args([
30+
service('meteo_concept_h_captcha.captcha_verifier'),
31+
'',
32+
])
33+
->tag('validator.constraint_validator');
34+
35+
$services->alias(\MeteoConcept\HCaptchaBundle\Validator\Constraints\IsValidCaptchaValidator::class, 'meteo_concept_h_captcha.captcha_validator')
36+
->private();
37+
38+
$services->set('meteo_concept_h_captcha.hcaptcha_form_type', \MeteoConcept\HCaptchaBundle\Form\HCaptchaType::class)
39+
->public()
40+
->args([
41+
service('meteo_concept_h_captcha.hcaptcha_value_fetcher'),
42+
'',
43+
])
44+
->tag('form.type', ['alias' => 'hcaptcha']);
45+
46+
$services->alias(\MeteoConcept\HCaptchaBundle\Form\HCaptchaType::class, 'meteo_concept_h_captcha.hcaptcha_form_type')
47+
->private();
48+
49+
$services->set('meteo_concept_h_captcha.hcaptcha_value_fetcher', \MeteoConcept\HCaptchaBundle\Form\DataTransformer\HCaptchaValueFetcher::class)
50+
->public()
51+
->args([service('request_stack')]);
52+
53+
$services->alias(\MeteoConcept\HCaptchaBundle\Form\DataTransformer\HCaptchaValueFetcher::class, 'meteo_concept_h_captcha.hcaptcha_value_fetcher')
54+
->private();
55+
};

Resources/config/services.xml

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)