File tree 1 file changed +25
-0
lines changed
components/dependency_injection
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,12 @@ processed when the container is compiled at which point the Extensions are loade
120
120
// ...
121
121
$container->compile();
122
122
123
+ .. note ::
124
+
125
+ When loading a config file that uses an extension alias as a key, the
126
+ extension must already have been registered with the container builder
127
+ or an exception will be thrown.
128
+
123
129
The values from those sections of the config files are passed into the first
124
130
argument of the ``load `` method of the extension::
125
131
@@ -240,6 +246,25 @@ but also load a secondary one only if a certain parameter is set::
240
246
}
241
247
}
242
248
249
+ .. note ::
250
+
251
+ Just registering an extension with the container is not enough to get
252
+ it included in the processed extensions when the container is compiled.
253
+ Loading config which uses the extension's alias as a key as in the above
254
+ examples will ensure it is loaded. The container builder can also be
255
+ told to load it with its
256
+ :method: `Symfony\\ Component\\ DependencyInjection\\ ContainerBuilder::loadFromExtension `
257
+ method::
258
+
259
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
260
+
261
+ $container = new ContainerBuilder();
262
+ $extension = new AcmeDemoExtension();
263
+ $container->registerExtension($extension);
264
+ $container->loadFromExtension($extension->getAlias());
265
+ $container->compile();
266
+
267
+
243
268
.. note ::
244
269
245
270
If you need to manipulate the configuration loaded by an extension then
You can’t perform that action at this time.
0 commit comments