@@ -20,29 +20,36 @@ 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"
3032 xmlns : framework =" http://symfony.com/schema/dic/symfony"
3133 xsi : schemaLocation =" http://symfony.com/schema/dic/services
3234 https://symfony.com/schema/dic/services/services-1.0.xsd
3335 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+ >
3638 <framework : config >
3739 <framework : form />
3840 </framework : config >
3941 </container >
4042
4143 .. code-block :: php
4244
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+ };
4653
4754 Using the Bundle Extension
4855--------------------------
@@ -69,24 +76,28 @@ can add some configuration that looks like this:
6976 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
7077 xmlns : acme-social =" http://example.org/schema/dic/acme_social"
7178 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+ >
7481 <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+ />
7685 </acme-social : config >
77-
78- <!-- ... -->
7986 </container >
8087
8188 .. code-block :: php
8289
8390 // 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+ };
90101
91102 The basic idea is that instead of having the user override individual
92103parameters, you let the user configure just a few, specifically created,
@@ -242,8 +253,8 @@ For example, imagine your bundle has the following example config:
242253 <container xmlns =" http://symfony.com/schema/dic/services"
243254 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
244255 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+ >
247258 <services >
248259 <service id =" acme.social.twitter_client" class =" Acme\SocialBundle\TwitterClient" >
249260 <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
423434 xsi : schemaLocation =" http://symfony.com/schema/dic/services
424435 https://symfony.com/schema/dic/services/services-1.0.xsd
425436 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+ >
428439 <acme-hello : config >
429440 <!-- ... -->
430441 </acme-hello : config >
0 commit comments