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