@@ -20,29 +20,37 @@ as integration of other related components:
20
20
21
21
.. code-block :: yaml
22
22
23
+ # config/packages/framework.yaml
23
24
framework :
24
25
form : true
25
26
26
27
.. code-block :: xml
27
28
29
+ <!-- config/packages/framework.xml -->
28
30
<?xml version =" 1.0" encoding =" UTF-8" ?>
29
31
<container xmlns =" http://symfony.com/schema/dic/services"
32
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
30
33
xmlns : framework =" http://symfony.com/schema/dic/symfony"
31
34
xsi : schemaLocation =" http://symfony.com/schema/dic/services
32
35
https://symfony.com/schema/dic/services/services-1.0.xsd
33
36
http://symfony.com/schema/dic/symfony
34
- https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
35
-
37
+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
38
+ >
36
39
<framework : config >
37
40
<framework : form />
38
41
</framework : config >
39
42
</container >
40
43
41
44
.. code-block :: php
42
45
43
- $container->loadFromExtension('framework', [
44
- 'form' => true,
45
- ]);
46
+ // config/packages/framework.php
47
+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
48
+
49
+ return static function (ContainerConfigurator $container) {
50
+ $container->extension('framework', [
51
+ 'form' => true,
52
+ ]);
53
+ };
46
54
47
55
Using the Bundle Extension
48
56
--------------------------
@@ -69,24 +77,28 @@ can add some configuration that looks like this:
69
77
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
70
78
xmlns : acme-social =" http://example.org/schema/dic/acme_social"
71
79
xsi : schemaLocation =" http://symfony.com/schema/dic/services
72
- https://symfony.com/schema/dic/services/services-1.0.xsd" >
73
-
80
+ https://symfony.com/schema/dic/services/services-1.0.xsd"
81
+ >
74
82
<acme-social : config >
75
- <acme-social : twitter client-id =" 123" client-secret =" your_secret" />
83
+ <acme-social : twitter client-id =" 123"
84
+ client-secret =" your_secret"
85
+ />
76
86
</acme-social : config >
77
-
78
- <!-- ... -->
79
87
</container >
80
88
81
89
.. code-block :: php
82
90
83
91
// config/packages/acme_social.php
84
- $container->loadFromExtension('acme_social', [
85
- 'twitter' => [
86
- 'client_id' => 123,
87
- 'client_secret' => 'your_secret',
88
- ],
89
- ]);
92
+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
93
+
94
+ return static function (ContainerConfigurator $container) {
95
+ $container->extension('acme_social', [
96
+ 'twitter' => [
97
+ 'client_id' => 123,
98
+ 'client_secret' => 'your_secret',
99
+ ],
100
+ ]);
101
+ };
90
102
91
103
The basic idea is that instead of having the user override individual
92
104
parameters, you let the user configure just a few, specifically created,
@@ -242,8 +254,8 @@ For example, imagine your bundle has the following example config:
242
254
<container xmlns =" http://symfony.com/schema/dic/services"
243
255
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
244
256
xsi : schemaLocation =" http://symfony.com/schema/dic/services
245
- https://symfony.com/schema/dic/services/services-1.0.xsd" >
246
-
257
+ https://symfony.com/schema/dic/services/services-1.0.xsd"
258
+ >
247
259
<services >
248
260
<service id =" acme.social.twitter_client" class =" Acme\SocialBundle\TwitterClient" >
249
261
<argument ></argument > <!-- will be filled in with client_id dynamically -->
@@ -423,8 +435,8 @@ Assuming the XSD file is called ``hello-1.0.xsd``, the schema location will be
423
435
xsi : schemaLocation =" http://symfony.com/schema/dic/services
424
436
https://symfony.com/schema/dic/services/services-1.0.xsd
425
437
http://acme_company.com/schema/dic/hello
426
- https://acme_company.com/schema/dic/hello/hello-1.0.xsd" >
427
-
438
+ https://acme_company.com/schema/dic/hello/hello-1.0.xsd"
439
+ >
428
440
<acme-hello : config >
429
441
<!-- ... -->
430
442
</acme-hello : config >
0 commit comments