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