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