53
53
use Symfony \Component \DependencyInjection \Exception \InvalidArgumentException ;
54
54
use Symfony \Component \DependencyInjection \Exception \LogicException ;
55
55
use Symfony \Component \DependencyInjection \Loader \PhpFileLoader ;
56
- use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
57
56
use Symfony \Component \DependencyInjection \Parameter ;
58
57
use Symfony \Component \DependencyInjection \Reference ;
59
58
use Symfony \Component \DependencyInjection \ServiceLocator ;
@@ -171,14 +170,12 @@ class FrameworkExtension extends Extension
171
170
*/
172
171
public function load (array $ configs , ContainerBuilder $ container )
173
172
{
174
- $ loader = new XmlFileLoader ($ container , new FileLocator (\dirname (__DIR__ ).'/Resources/config ' ));
173
+ $ loader = new PhpFileLoader ($ container , new FileLocator (\dirname (__DIR__ ).'/Resources/config ' ));
175
174
176
- $ phpLoader = new PhpFileLoader ($ container , new FileLocator (\dirname (__DIR__ ).'/Resources/config ' ));
177
-
178
- $ phpLoader ->load ('web.php ' );
179
- $ phpLoader ->load ('services.php ' );
180
- $ phpLoader ->load ('fragment_renderer.php ' );
181
- $ phpLoader ->load ('error_renderer.php ' );
175
+ $ loader ->load ('web.php ' );
176
+ $ loader ->load ('services.php ' );
177
+ $ loader ->load ('fragment_renderer.php ' );
178
+ $ loader ->load ('error_renderer.php ' );
182
179
183
180
if (interface_exists (PsrEventDispatcherInterface::class)) {
184
181
$ container ->setAlias (PsrEventDispatcherInterface::class, 'event_dispatcher ' );
@@ -187,7 +184,7 @@ public function load(array $configs, ContainerBuilder $container)
187
184
$ container ->registerAliasForArgument ('parameter_bag ' , PsrContainerInterface::class);
188
185
189
186
if (class_exists (Application::class)) {
190
- $ phpLoader ->load ('console.php ' );
187
+ $ loader ->load ('console.php ' );
191
188
192
189
if (!class_exists (BaseXliffLintCommand::class)) {
193
190
$ container ->removeDefinition ('console.command.xliff_lint ' );
@@ -198,7 +195,7 @@ public function load(array $configs, ContainerBuilder $container)
198
195
}
199
196
200
197
// Load Cache configuration first as it is used by other components
201
- $ phpLoader ->load ('cache.php ' );
198
+ $ loader ->load ('cache.php ' );
202
199
203
200
$ configuration = $ this ->getConfiguration ($ configs , $ container );
204
201
$ config = $ this ->processConfiguration ($ configuration , $ configs );
@@ -215,7 +212,7 @@ public function load(array $configs, ContainerBuilder $container)
215
212
}
216
213
217
214
if (class_exists (Translator::class)) {
218
- $ phpLoader ->load ('identity_translator.php ' );
215
+ $ loader ->load ('identity_translator.php ' );
219
216
}
220
217
}
221
218
@@ -266,7 +263,7 @@ public function load(array $configs, ContainerBuilder $container)
266
263
}
267
264
268
265
if (!empty ($ config ['test ' ])) {
269
- $ phpLoader ->load ('test.php ' );
266
+ $ loader ->load ('test.php ' );
270
267
271
268
if (!class_exists (AbstractBrowser::class)) {
272
269
$ container ->removeDefinition ('test.client ' );
@@ -282,28 +279,28 @@ public function load(array $configs, ContainerBuilder $container)
282
279
}
283
280
284
281
$ this ->sessionConfigEnabled = true ;
285
- $ this ->registerSessionConfiguration ($ config ['session ' ], $ container , $ phpLoader );
282
+ $ this ->registerSessionConfiguration ($ config ['session ' ], $ container , $ loader );
286
283
if (!empty ($ config ['test ' ])) {
287
284
$ container ->getDefinition ('test.session.listener ' )->setArgument (1 , '%session.storage.options% ' );
288
285
}
289
286
}
290
287
291
288
if ($ this ->isConfigEnabled ($ container , $ config ['request ' ])) {
292
- $ this ->registerRequestConfiguration ($ config ['request ' ], $ container , $ phpLoader );
289
+ $ this ->registerRequestConfiguration ($ config ['request ' ], $ container , $ loader );
293
290
}
294
291
295
292
if (null === $ config ['csrf_protection ' ]['enabled ' ]) {
296
293
$ config ['csrf_protection ' ]['enabled ' ] = $ this ->sessionConfigEnabled && !class_exists (FullStack::class) && interface_exists (CsrfTokenManagerInterface::class);
297
294
}
298
- $ this ->registerSecurityCsrfConfiguration ($ config ['csrf_protection ' ], $ container , $ phpLoader );
295
+ $ this ->registerSecurityCsrfConfiguration ($ config ['csrf_protection ' ], $ container , $ loader );
299
296
300
297
if ($ this ->isConfigEnabled ($ container , $ config ['form ' ])) {
301
298
if (!class_exists ('Symfony\Component\Form\Form ' )) {
302
299
throw new LogicException ('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form". ' );
303
300
}
304
301
305
302
$ this ->formConfigEnabled = true ;
306
- $ this ->registerFormConfiguration ($ config , $ container , $ phpLoader );
303
+ $ this ->registerFormConfiguration ($ config , $ container , $ loader );
307
304
308
305
if (class_exists ('Symfony\Component\Validator\Validation ' )) {
309
306
$ config ['validation ' ]['enabled ' ] = true ;
@@ -322,11 +319,11 @@ public function load(array $configs, ContainerBuilder $container)
322
319
throw new LogicException ('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset". ' );
323
320
}
324
321
325
- $ this ->registerAssetsConfiguration ($ config ['assets ' ], $ container , $ phpLoader );
322
+ $ this ->registerAssetsConfiguration ($ config ['assets ' ], $ container , $ loader );
326
323
}
327
324
328
325
if ($ this ->messengerConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['messenger ' ])) {
329
- $ this ->registerMessengerConfiguration ($ config ['messenger ' ], $ container , $ phpLoader , $ config ['validation ' ]);
326
+ $ this ->registerMessengerConfiguration ($ config ['messenger ' ], $ container , $ loader , $ config ['validation ' ]);
330
327
} else {
331
328
$ container ->removeDefinition ('console.command.messenger_consume_messages ' );
332
329
$ container ->removeDefinition ('console.command.messenger_debug ' );
@@ -359,54 +356,54 @@ public function load(array $configs, ContainerBuilder $container)
359
356
}
360
357
361
358
if ($ this ->httpClientConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['http_client ' ])) {
362
- $ this ->registerHttpClientConfiguration ($ config ['http_client ' ], $ container , $ phpLoader , $ config ['profiler ' ]);
359
+ $ this ->registerHttpClientConfiguration ($ config ['http_client ' ], $ container , $ loader , $ config ['profiler ' ]);
363
360
}
364
361
365
362
if ($ this ->mailerConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['mailer ' ])) {
366
- $ this ->registerMailerConfiguration ($ config ['mailer ' ], $ container , $ phpLoader );
363
+ $ this ->registerMailerConfiguration ($ config ['mailer ' ], $ container , $ loader );
367
364
}
368
365
369
366
if ($ this ->isConfigEnabled ($ container , $ config ['notifier ' ])) {
370
- $ this ->registerNotifierConfiguration ($ config ['notifier ' ], $ container , $ phpLoader );
367
+ $ this ->registerNotifierConfiguration ($ config ['notifier ' ], $ container , $ loader );
371
368
}
372
369
373
370
$ propertyInfoEnabled = $ this ->isConfigEnabled ($ container , $ config ['property_info ' ]);
374
- $ this ->registerValidationConfiguration ($ config ['validation ' ], $ container , $ phpLoader , $ propertyInfoEnabled );
371
+ $ this ->registerValidationConfiguration ($ config ['validation ' ], $ container , $ loader , $ propertyInfoEnabled );
375
372
$ this ->registerHttpCacheConfiguration ($ config ['http_cache ' ], $ container );
376
- $ this ->registerEsiConfiguration ($ config ['esi ' ], $ container , $ phpLoader );
377
- $ this ->registerSsiConfiguration ($ config ['ssi ' ], $ container , $ phpLoader );
378
- $ this ->registerFragmentsConfiguration ($ config ['fragments ' ], $ container , $ phpLoader );
379
- $ this ->registerTranslatorConfiguration ($ config ['translator ' ], $ container , $ phpLoader , $ config ['default_locale ' ]);
380
- $ this ->registerProfilerConfiguration ($ config ['profiler ' ], $ container , $ loader, $ phpLoader );
381
- $ this ->registerWorkflowConfiguration ($ config ['workflows ' ], $ container , $ phpLoader );
382
- $ this ->registerDebugConfiguration ($ config ['php_errors ' ], $ container , $ phpLoader );
383
- $ this ->registerRouterConfiguration ($ config ['router ' ], $ container , $ phpLoader , $ config ['translator ' ]['enabled_locales ' ] ?? []);
384
- $ this ->registerAnnotationsConfiguration ($ config ['annotations ' ], $ container , $ phpLoader );
385
- $ this ->registerPropertyAccessConfiguration ($ config ['property_access ' ], $ container , $ phpLoader );
386
- $ this ->registerSecretsConfiguration ($ config ['secrets ' ], $ container , $ phpLoader );
373
+ $ this ->registerEsiConfiguration ($ config ['esi ' ], $ container , $ loader );
374
+ $ this ->registerSsiConfiguration ($ config ['ssi ' ], $ container , $ loader );
375
+ $ this ->registerFragmentsConfiguration ($ config ['fragments ' ], $ container , $ loader );
376
+ $ this ->registerTranslatorConfiguration ($ config ['translator ' ], $ container , $ loader , $ config ['default_locale ' ]);
377
+ $ this ->registerProfilerConfiguration ($ config ['profiler ' ], $ container , $ loader );
378
+ $ this ->registerWorkflowConfiguration ($ config ['workflows ' ], $ container , $ loader );
379
+ $ this ->registerDebugConfiguration ($ config ['php_errors ' ], $ container , $ loader );
380
+ $ this ->registerRouterConfiguration ($ config ['router ' ], $ container , $ loader , $ config ['translator ' ]['enabled_locales ' ] ?? []);
381
+ $ this ->registerAnnotationsConfiguration ($ config ['annotations ' ], $ container , $ loader );
382
+ $ this ->registerPropertyAccessConfiguration ($ config ['property_access ' ], $ container , $ loader );
383
+ $ this ->registerSecretsConfiguration ($ config ['secrets ' ], $ container , $ loader );
387
384
388
385
if ($ this ->isConfigEnabled ($ container , $ config ['serializer ' ])) {
389
386
if (!class_exists ('Symfony\Component\Serializer\Serializer ' )) {
390
387
throw new LogicException ('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack". ' );
391
388
}
392
389
393
- $ this ->registerSerializerConfiguration ($ config ['serializer ' ], $ container , $ phpLoader );
390
+ $ this ->registerSerializerConfiguration ($ config ['serializer ' ], $ container , $ loader );
394
391
}
395
392
396
393
if ($ propertyInfoEnabled ) {
397
- $ this ->registerPropertyInfoConfiguration ($ container , $ phpLoader );
394
+ $ this ->registerPropertyInfoConfiguration ($ container , $ loader );
398
395
}
399
396
400
397
if ($ this ->isConfigEnabled ($ container , $ config ['lock ' ])) {
401
- $ this ->registerLockConfiguration ($ config ['lock ' ], $ container , $ phpLoader );
398
+ $ this ->registerLockConfiguration ($ config ['lock ' ], $ container , $ loader );
402
399
}
403
400
404
401
if ($ this ->isConfigEnabled ($ container , $ config ['web_link ' ])) {
405
402
if (!class_exists (HttpHeaderSerializer::class)) {
406
403
throw new LogicException ('WebLink support cannot be enabled as the WebLink component is not installed. Try running "composer require symfony/weblink". ' );
407
404
}
408
405
409
- $ phpLoader ->load ('web_link.php ' );
406
+ $ loader ->load ('web_link.php ' );
410
407
}
411
408
412
409
$ this ->addAnnotatedClassesToCompile ([
@@ -418,7 +415,7 @@ public function load(array $configs, ContainerBuilder $container)
418
415
]);
419
416
420
417
if (class_exists (MimeTypes::class)) {
421
- $ phpLoader ->load ('mime_type.php ' );
418
+ $ loader ->load ('mime_type.php ' );
422
419
}
423
420
424
421
$ container ->registerForAutoconfiguration (Command::class)
@@ -590,7 +587,7 @@ private function registerFragmentsConfiguration(array $config, ContainerBuilder
590
587
$ container ->setParameter ('fragment.path ' , $ config ['path ' ]);
591
588
}
592
589
593
- private function registerProfilerConfiguration (array $ config , ContainerBuilder $ container , XmlFileLoader $ loader , PhpFileLoader $ phpLoader )
590
+ private function registerProfilerConfiguration (array $ config , ContainerBuilder $ container , PhpFileLoader $ loader )
594
591
{
595
592
if (!$ this ->isConfigEnabled ($ container , $ config )) {
596
593
// this is needed for the WebProfiler to work even if the profiler is disabled
@@ -599,34 +596,34 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
599
596
return ;
600
597
}
601
598
602
- $ phpLoader ->load ('profiling.php ' );
603
- $ phpLoader ->load ('collectors.php ' );
604
- $ phpLoader ->load ('cache_debug.php ' );
599
+ $ loader ->load ('profiling.php ' );
600
+ $ loader ->load ('collectors.php ' );
601
+ $ loader ->load ('cache_debug.php ' );
605
602
606
603
if ($ this ->formConfigEnabled ) {
607
- $ phpLoader ->load ('form_debug.php ' );
604
+ $ loader ->load ('form_debug.php ' );
608
605
}
609
606
610
607
if ($ this ->validatorConfigEnabled ) {
611
- $ phpLoader ->load ('validator_debug.php ' );
608
+ $ loader ->load ('validator_debug.php ' );
612
609
}
613
610
614
611
if ($ this ->translationConfigEnabled ) {
615
- $ phpLoader ->load ('translation_debug.php ' );
612
+ $ loader ->load ('translation_debug.php ' );
616
613
617
614
$ container ->getDefinition ('translator.data_collector ' )->setDecoratedService ('translator ' );
618
615
}
619
616
620
617
if ($ this ->messengerConfigEnabled ) {
621
- $ phpLoader ->load ('messenger_debug.php ' );
618
+ $ loader ->load ('messenger_debug.php ' );
622
619
}
623
620
624
621
if ($ this ->mailerConfigEnabled ) {
625
- $ phpLoader ->load ('mailer_debug.php ' );
622
+ $ loader ->load ('mailer_debug.php ' );
626
623
}
627
624
628
625
if ($ this ->httpClientConfigEnabled ) {
629
- $ phpLoader ->load ('http_client_debug.php ' );
626
+ $ loader ->load ('http_client_debug.php ' );
630
627
}
631
628
632
629
$ container ->setParameter ('profiler_listener.only_exceptions ' , $ config ['only_exceptions ' ]);
@@ -1458,7 +1455,7 @@ private function registerSecretsConfiguration(array $config, ContainerBuilder $c
1458
1455
}
1459
1456
}
1460
1457
1461
- private function registerSecurityCsrfConfiguration (array $ config , ContainerBuilder $ container , PhpFileLoader $ phpLoader )
1458
+ private function registerSecurityCsrfConfiguration (array $ config , ContainerBuilder $ container , PhpFileLoader $ loader )
1462
1459
{
1463
1460
if (!$ this ->isConfigEnabled ($ container , $ config )) {
1464
1461
return ;
@@ -1473,7 +1470,7 @@ private function registerSecurityCsrfConfiguration(array $config, ContainerBuild
1473
1470
}
1474
1471
1475
1472
// Enable services for CSRF protection (even without forms)
1476
- $ phpLoader ->load ('security_csrf.php ' );
1473
+ $ loader ->load ('security_csrf.php ' );
1477
1474
1478
1475
if (!class_exists (CsrfExtension::class)) {
1479
1476
$ container ->removeDefinition ('twig.extension.security_csrf ' );
0 commit comments