@@ -20,29 +20,37 @@ as integration of other related components:
2020
2121 .. code-block :: yaml
2222
23+ # config/packages/framework.yaml
2324 framework :
2425 form : true
2526
2627 .. code-block :: xml
2728
29+ <!-- config/packages/framework.xml -->
2830 <?xml version =" 1.0" encoding =" UTF-8" ?>
2931 <container xmlns =" http://symfony.com/schema/dic/services"
32+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3033 xmlns : framework =" http://symfony.com/schema/dic/symfony"
3134 xsi : schemaLocation =" http://symfony.com/schema/dic/services
3235 https://symfony.com/schema/dic/services/services-1.0.xsd
3336 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+ >
3639 <framework : config >
3740 <framework : form />
3841 </framework : config >
3942 </container >
4043
4144 .. code-block :: php
4245
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+ };
4654
4755 Using the Bundle Extension
4856--------------------------
@@ -69,24 +77,28 @@ can add some configuration that looks like this:
6977 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
7078 xmlns : acme-social =" http://example.org/schema/dic/acme_social"
7179 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+ >
7482 <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+ />
7686 </acme-social : config >
77-
78- <!-- ... -->
7987 </container >
8088
8189 .. code-block :: php
8290
8391 // 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+ };
90102
91103 The basic idea is that instead of having the user override individual
92104parameters, you let the user configure just a few, specifically created,
@@ -242,8 +254,8 @@ For example, imagine your bundle has the following example config:
242254 <container xmlns =" http://symfony.com/schema/dic/services"
243255 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
244256 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+ >
247259 <services >
248260 <service id =" acme.social.twitter_client" class =" Acme\SocialBundle\TwitterClient" >
249261 <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
423435 xsi : schemaLocation =" http://symfony.com/schema/dic/services
424436 https://symfony.com/schema/dic/services/services-1.0.xsd
425437 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+ >
428440 <acme-hello : config >
429441 <!-- ... -->
430442 </acme-hello : config >
0 commit comments