@@ -163,14 +163,21 @@ Now it looks like this::
163
163
protected function configureContainer(ContainerConfigurator $c): void
164
164
{
165
165
$c->import(__DIR__.'/../config/framework.yaml');
166
- $c->import(__DIR__.'/../config/web_profiler.yaml');
167
166
168
167
// register all classes in /src/ as service
169
168
$c->services()
170
169
->load('App\\', __DIR__.'/*')
171
170
->autowire()
172
171
->autoconfigure()
173
172
;
173
+
174
+ // configure WebProfilerBundle only if the bundle is enabled
175
+ if (isset($this->bundles['WebProfilerBundle'])) {
176
+ $c->extension('web_profiler', [
177
+ 'toolbar' => true,
178
+ 'intercept_redirects' => false,
179
+ ]);
180
+ }
174
181
}
175
182
176
183
protected function configureRoutes(RoutingConfigurator $routes): void
@@ -229,11 +236,15 @@ add a service conditionally based on the ``foo`` value::
229
236
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
230
237
{
231
238
if ($config['foo']) {
232
- $container->set('foo_service', new stdClass());
239
+ $container->set('foo_service', new \ stdClass());
233
240
}
234
241
}
235
242
}
236
243
244
+ .. versionadded :: 6.1
245
+
246
+ The ``AbstractExtension `` class is introduced in Symfony 6.1.
247
+
237
248
Unlike the previous kernel, this loads an external ``config/framework.yaml `` file,
238
249
because the configuration started to get bigger:
239
250
@@ -274,46 +285,6 @@ because the configuration started to get bigger:
274
285
;
275
286
};
276
287
277
- As well as the ``config/web_profiler.yaml `` file:
278
-
279
- .. configuration-block ::
280
-
281
- .. code-block :: yaml
282
-
283
- # config/web_profiler.yaml
284
- when@dev :
285
- web_profiler :
286
- toolbar : true
287
- intercept_redirects : false
288
-
289
- .. code-block :: xml
290
-
291
- <!-- config/web_profiler.xml -->
292
- <?xml version =" 1.0" encoding =" UTF-8" ?>
293
- <container xmlns =" http://symfony.com/schema/dic/services"
294
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
295
- xmlns : framework =" http://symfony.com/schema/dic/symfony"
296
- xsi : schemaLocation =" http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
297
- http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
298
-
299
- <!-- WebProfilerBundle is enabled only in the "dev" environment -->
300
- <when env =" dev" >
301
- <web-profiler : config toolbar =" true" intercept-redirects =" false" />
302
- </when >
303
- </container >
304
-
305
- .. code-block :: php
306
-
307
- // config/web_profiler.php
308
- use Symfony\Config\WebProfilerConfig;
309
-
310
- return static function (WebProfilerConfig $webProfiler) {
311
- $webProfiler
312
- ->toolbar(true)
5E24
313
- ->interceptRedirects(false)
314
- ;
315
- };
316
-
317
288
This also loads annotation routes from an ``src/Controller/ `` directory, which
318
289
has one file in it::
319
290
0 commit comments