@@ -345,26 +345,6 @@ public function load(array $configs, ContainerBuilder $container)
345
345
$ this ->registerRequestConfiguration ($ config ['request ' ], $ container , $ loader );
346
346
}
347
347
348
- if ($ this ->isConfigEnabled ($ container , $ config ['form ' ])) {
349
- if (!class_exists (Form::class)) {
350
- throw new LogicException ('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form". ' );
351
- }
352
-
353
- $ this ->formConfigEnabled = true ;
354
- $ this ->registerFormConfiguration ($ config , $ container , $ loader );
355
-
356
- if (ContainerBuilder::willBeAvailable ('symfony/validator ' , Validation::class, ['symfony/framework-bundle ' , 'symfony/form ' ], true )) {
357
- $ config ['validation ' ]['enabled ' ] = true ;
358
- } else {
359
- $ container ->setParameter ('validator.translation_domain ' , 'validators ' );
360
-
361
- $ container ->removeDefinition ('form.type_extension.form.validator ' );
362
- $ container ->removeDefinition ('form.type_guesser.validator ' );
363
- }
364
- } else {
365
- $ container ->removeDefinition ('console.command.form_debug ' );
366
- }
367
-
368
348
if ($ this ->isConfigEnabled ($ container , $ config ['assets ' ])) {
369
349
if (!class_exists (\Symfony \Component \Asset \Package::class)) {
370
350
throw new LogicException ('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset". ' );
@@ -373,39 +353,6 @@ public function load(array $configs, ContainerBuilder $container)
373
353
$ this ->registerAssetsConfiguration ($ config ['assets ' ], $ container , $ loader );
374
354
}
375
355
376
- if ($ this ->messengerConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['messenger ' ])) {
377
- $ this ->registerMessengerConfiguration ($ config ['messenger ' ], $ container , $ loader , $ config ['validation ' ]);
378
- } else {
379
- $ container ->removeDefinition ('console.command.messenger_consume_messages ' );
380
- $ container ->removeDefinition ('console.command.messenger_debug ' );
381
- $ container ->removeDefinition ('console.command.messenger_stop_workers ' );
382
- $ container ->removeDefinition ('console.command.messenger_setup_transports ' );
383
- $ container ->removeDefinition ('console.command.messenger_failed_messages_retry ' );
384
- $ container ->removeDefinition ('console.command.messenger_failed_messages_show ' );
385
- $ container ->removeDefinition ('console.command.messenger_failed_messages_remove ' );
386
- $ container ->removeDefinition ('cache.messenger.restart_workers_signal ' );
387
-
388
- if ($ container ->hasDefinition ('messenger.transport.amqp.factory ' ) && !class_exists (AmqpTransportFactory::class)) {
389
- if (class_exists (\Symfony \Component \Messenger \Transport \AmqpExt \AmqpTransportFactory::class)) {
390
- $ container ->getDefinition ('messenger.transport.amqp.factory ' )
391
- ->setClass (\Symfony \Component \Messenger \Transport \AmqpExt \AmqpTransportFactory::class)
392
- ->addTag ('messenger.transport_factory ' );
393
- } else {
394
- $ container ->removeDefinition ('messenger.transport.amqp.factory ' );
395
- }
396
- }
397
-
398
- if ($ container ->hasDefinition ('messenger.transport.redis.factory ' ) && !class_exists (RedisTransportFactory::class)) {
399
- if (class_exists (\Symfony \Component \Messenger \Transport \RedisExt \RedisTransportFactory::class)) {
400
- $ container ->getDefinition ('messenger.transport.redis.factory ' )
401
- ->setClass (\Symfony \Component \Messenger \Transport \RedisExt \RedisTransportFactory::class)
402
- ->addTag ('messenger.transport_factory ' );
403
- } else {
404
- $ container ->removeDefinition ('messenger.transport.redis.factory ' );
405
- }
406
- }
407
- }
408
-
409
356
if ($ this ->httpClientConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['http_client ' ])) {
410
357
$ this ->registerHttpClientConfiguration ($ config ['http_client ' ], $ container , $ loader , $ config ['profiler ' ]);
411
358
}
@@ -414,18 +361,12 @@ public function load(array $configs, ContainerBuilder $container)
414
361
$ this ->registerMailerConfiguration ($ config ['mailer ' ], $ container , $ loader );
415
362
}
416
363
417
- if ($ this ->notifierConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['notifier ' ])) {
418
- $ this ->registerNotifierConfiguration ($ config ['notifier ' ], $ container , $ loader );
419
- }
420
-
421
364
$ propertyInfoEnabled = $ this ->isConfigEnabled ($ container , $ config ['property_info ' ]);
422
- $ this ->registerValidationConfiguration ($ config ['validation ' ], $ container , $ loader , $ propertyInfoEnabled );
423
365
$ this ->registerHttpCacheConfiguration ($ config ['http_cache ' ], $ container , $ config ['http_method_override ' ]);
424
366
$ this ->registerEsiConfiguration ($ config ['esi ' ], $ container , $ loader );
425
367
$ this ->registerSsiConfiguration ($ config ['ssi ' ], $ container , $ loader );
426
368
$ this ->registerFragmentsConfiguration ($ config ['fragments ' ], $ container , $ loader );
427
369
$ this ->registerTranslatorConfiguration ($ config ['translator ' ], $ container , $ loader , $ config ['default_locale ' ], $ config ['enabled_locales ' ]);
428
- $ this ->registerProfilerConfiguration ($ config ['profiler ' ], $ container , $ loader );
429
370
$ this ->registerWorkflowConfiguration ($ config ['workflows ' ], $ container , $ loader );
430
371
$ this ->registerDebugConfiguration ($ config ['php_errors ' ], $ container , $ loader );
431
372
// @deprecated since Symfony 5.4, in 6.0 change to:
@@ -502,6 +443,72 @@ public function load(array $configs, ContainerBuilder $container)
502
443
}
503
444
$ this ->registerSecurityCsrfConfiguration ($ config ['csrf_protection ' ], $ container , $ loader );
504
445
446
+ // form depends on csrf being registered
447
+ if ($ this ->isConfigEnabled ($ container , $ config ['form ' ])) {
448
+ if (!class_exists (Form::class)) {
449
+ throw new LogicException ('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form". ' );
450
+ }
451
+
452
+ $ this ->formConfigEnabled = true ;
453
+ $ this ->registerFormConfiguration ($ config , $ container , $ loader );
454
+
455
+ if (ContainerBuilder::willBeAvailable ('symfony/validator ' , Validation::class, ['symfony/framework-bundle ' , 'symfony/form ' ], true )) {
456
+ $ config ['validation ' ]['enabled ' ] = true ;
457
+ } else {
458
+ $ container ->setParameter ('validator.translation_domain ' , 'validators ' );
459
+
460
+ $ container ->removeDefinition ('form.type_extension.form.validator ' );
461
+ $ container ->removeDefinition ('form.type_guesser.validator ' );
462
+ }
463
+ } else {
464
+ $ container ->removeDefinition ('console.command.form_debug ' );
465
+ }
466
+
467
+ // validation depends on form, annotations being registered
468
+ $ this ->registerValidationConfiguration ($ config ['validation ' ], $ container , $ loader , $ propertyInfoEnabled );
469
+
470
+ // messenger depends on validation being registered
471
+ if ($ this ->messengerConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['messenger ' ])) {
472
+ $ this ->registerMessengerConfiguration ($ config ['messenger ' ], $ container , $ loader , $ config ['validation ' ]);
473
+ } else {
474
+ $ container ->removeDefinition ('console.command.messenger_consume_messages ' );
475
+ $ container ->removeDefinition ('console.command.messenger_debug ' );
476
+ $ container ->removeDefinition ('console.command.messenger_stop_workers ' );
477
+ $ container ->removeDefinition ('console.command.messenger_setup_transports ' );
478
+ $ container ->removeDefinition ('console.command.messenger_failed_messages_retry ' );
479
+ $ container ->removeDefinition ('console.command.messenger_failed_messages_show ' );
480
+ $ container ->removeDefinition ('console.command.messenger_failed_messages_remove ' );
481
+ $ container ->removeDefinition ('cache.messenger.restart_workers_signal ' );
482
+
483
+ if ($ container ->hasDefinition ('messenger.transport.amqp.factory ' ) && !class_exists (AmqpTransportFactory::class)) {
484
+ if (class_exists (\Symfony \Component \Messenger \Transport \AmqpExt \AmqpTransportFactory::class)) {
485
+ $ container ->getDefinition ('messenger.transport.amqp.factory ' )
486
+ ->setClass (\Symfony \Component \Messenger \Transport \AmqpExt \AmqpTransportFactory::class)
487
+ ->addTag ('messenger.transport_factory ' );
488
+ } else {
489
+ $ container ->removeDefinition ('messenger.transport.amqp.factory ' );
490
+ }
491
+ }
492
+
493
+ if ($ container ->hasDefinition ('messenger.transport.redis.factory ' ) && !class_exists (RedisTransportFactory::class)) {
494
+ if (class_exists (\Symfony \Component \Messenger \Transport \RedisExt \RedisTransportFactory::class)) {
495
+ $ container ->getDefinition ('messenger.transport.redis.factory ' )
496
+ ->setClass (\Symfony \Component \Messenger \Transport \RedisExt \RedisTransportFactory::class)
497
+ ->addTag ('messenger.transport_factory ' );
498
+ } else {
499
+ $ container ->removeDefinition ('messenger.transport.redis.factory ' );
500
+ }
501
+ }
502
+ }
503
+
504
+ // notifier depends on messenger, mailer being registered
505
+ if ($ this ->notifierConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['notifier ' ])) {
506
+ $ this ->registerNotifierConfiguration ($ config ['notifier ' ], $ container , $ loader );
507
+ }
508
+
509
+ // profiler depends on form, validation, translation, messenger, mailer, http-client, notifier being registered
510
+ $ this ->registerProfilerConfiguration ($ config ['profiler ' ], $ container , $ loader );
511
+
505
512
$ this ->addAnnotatedClassesToCompile ([
506
513
'** \\Controller \\' ,
507
514
'** \\Entity \\' ,
0 commit comments