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