11
11
12
12
namespace Symfony \Bundle \FrameworkBundle \DependencyInjection ;
13
13
14
- use Composer \InstalledVersions ;
15
14
use Doctrine \Common \Annotations \AnnotationRegistry ;
16
15
use Doctrine \Common \Annotations \Reader ;
17
16
use Http \Client \HttpClient ;
@@ -234,18 +233,14 @@ class FrameworkExtension extends Extension
234
233
*/
235
234
public function load (array $ configs , ContainerBuilder $ container )
236
235
{
237
- if (!class_exists (InstalledVersions::class)) {
238
- trigger_deprecation ('symfony/framework-bundle ' , '5.4 ' , 'Configuring Symfony without the Composer Runtime API is deprecated. Consider upgrading to Composer 2.1 or later. ' );
239
- }
240
-
241
236
$ loader = new PhpFileLoader ($ container , new FileLocator (\dirname (__DIR__ ).'/Resources/config ' ));
242
237
243
238
$ loader ->load ('web.php ' );
244
239
$ loader ->load ('services.php ' );
245
240
$ loader ->load ('fragment_renderer.php ' );
246
241
$ loader ->load ('error_renderer.php ' );
247
242
248
- if (ContainerBuilder::willBeAvailable ('psr/event-dispatcher ' , PsrEventDispatcherInterface::class, ['symfony/framework-bundle ' ], true )) {
243
+ if (ContainerBuilder::willBeAvailable ('psr/event-dispatcher ' , PsrEventDispatcherInterface::class, ['symfony/framework-bundle ' ])) {
249
244
$ container ->setAlias (PsrEventDispatcherInterface::class, 'event_dispatcher ' );
250
245
}
251
246
@@ -292,11 +287,11 @@ public function load(array $configs, ContainerBuilder $container)
292
287
$ container ->getDefinition ('response_listener ' )->replaceArgument (1 , $ config ['set_content_language_from_locale ' ]);
293
288
294
289
// If the slugger is used but the String component is not available, we should throw an error
295
- if (!ContainerBuilder::willBeAvailable ('symfony/string ' , SluggerInterface::class, ['symfony/framework-bundle ' ], true )) {
290
+ if (!ContainerBuilder::willBeAvailable ('symfony/string ' , SluggerInterface::class, ['symfony/framework-bundle ' ])) {
296
291
$ container ->register ('slugger ' , 'stdClass ' )
297
292
->addError ('You cannot use the "slugger" service since the String component is not installed. Try running "composer require symfony/string". ' );
298
293
} else {
299
- if (!ContainerBuilder::willBeAvailable ('symfony/translation ' , LocaleAwareInterface::class, ['symfony/framework-bundle ' ], true )) {
294
+ if (!ContainerBuilder::willBeAvailable ('symfony/translation ' , LocaleAwareInterface::class, ['symfony/framework-bundle ' ])) {
300
295
$ container ->register ('slugger ' , 'stdClass ' )
301
296
->addError ('You cannot use the "slugger" service since the Translation contracts are not installed. Try running "composer require symfony/translation". ' );
302
297
}
@@ -352,7 +347,7 @@ public function load(array $configs, ContainerBuilder $container)
352
347
}
353
348
354
349
if (null === $ config ['csrf_protection ' ]['enabled ' ]) {
355
- $ config ['csrf_protection ' ]['enabled ' ] = $ this ->sessionConfigEnabled && !class_exists (FullStack::class) && ContainerBuilder::willBeAvailable ('symfony/security-csrf ' , CsrfTokenManagerInterface::class, ['symfony/framework-bundle ' ], true );
350
+ $ config ['csrf_protection ' ]['enabled ' ] = $ this ->sessionConfigEnabled && !class_exists (FullStack::class) && ContainerBuilder::willBeAvailable ('symfony/security-csrf ' , CsrfTokenManagerInterface::class, ['symfony/framework-bundle ' ]);
356
351
}
357
352
$ this ->registerSecurityCsrfConfiguration ($ config ['csrf_protection ' ], $ container , $ loader );
358
353
@@ -364,7 +359,7 @@ public function load(array $configs, ContainerBuilder $container)
364
359
$ this ->formConfigEnabled = true ;
365
360
$ this ->registerFormConfiguration ($ config , $ container , $ loader );
366
361
367
- if (ContainerBuilder::willBeAvailable ('symfony/validator ' , Validation::class, ['symfony/framework-bundle ' , 'symfony/form ' ], true )) {
362
+ if (ContainerBuilder::willBeAvailable ('symfony/validator ' , Validation::class, ['symfony/framework-bundle ' , 'symfony/form ' ])) {
368
363
$ config ['validation ' ]['enabled ' ] = true ;
369
364
} else {
370
365
$ container ->setParameter ('validator.translation_domain ' , 'validators ' );
@@ -494,7 +489,7 @@ public function load(array $configs, ContainerBuilder $container)
494
489
'Symfony \\Bundle \\FrameworkBundle \\Controller \\AbstractController ' ,
495
490
]);
496
491
497
- if (ContainerBuilder::willBeAvailable ('symfony/mime ' , MimeTypes::class, ['symfony/framework-bundle ' ], true )) {
492
+ if (ContainerBuilder::willBeAvailable ('symfony/mime ' , MimeTypes::class, ['symfony/framework-bundle ' ])) {
498
493
$ loader ->load ('mime_type.php ' );
499
494
}
500
495
@@ -647,7 +642,7 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont
647
642
$ container ->setParameter ('form.type_extension.csrf.enabled ' , false );
648
643
}
649
644
650
- if (!ContainerBuilder::willBeAvailable ('symfony/translation ' , Translator::class, ['symfony/framework-bundle ' , 'symfony/form ' ], true )) {
645
+ if (!ContainerBuilder::willBeAvailable ('symfony/translation ' , Translator::class, ['symfony/framework-bundle ' , 'symfony/form ' ])) {
651
646
$ container ->removeDefinition ('form.type_extension.upload.validator ' );
652
647
}
653
648
if (!method_exists (CachingFactoryDecorator::class, 'reset ' )) {
@@ -1030,7 +1025,7 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
1030
1025
$ container ->getDefinition ('routing.loader ' )->replaceArgument (2 , ['_locale ' => $ enabledLocales ]);
1031
1026
}
1032
1027
1033
- if (!ContainerBuilder::willBeAvailable ('symfony/expression-language ' , ExpressionLanguage::class, ['symfony/framework-bundle ' , 'symfony/routing ' ], true )) {
1028
+ if (!ContainerBuilder::willBeAvailable ('symfony/expression-language ' , ExpressionLanguage::class, ['symfony/framework-bundle ' , 'symfony/routing ' ])) {
1034
1029
$ container ->removeDefinition ('router.expression_language_provider ' );
1035
1030
}
1036
1031
@@ -1244,17 +1239,17 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
1244
1239
$ dirs = [];
1245
1240
$ transPaths = [];
1246
1241
$ nonExistingDirs = [];
1247
- if (ContainerBuilder::willBeAvailable ('symfony/validator ' , Validation::class, ['symfony/framework-bundle ' , 'symfony/translation ' ], true )) {
1242
+ if (ContainerBuilder::willBeAvailable ('symfony/validator ' , Validation::class, ['symfony/framework-bundle ' , 'symfony/translation ' ])) {
1248
1243
$ r = new \ReflectionClass (Validation::class);
1249
1244
1250
1245
$ dirs [] = $ transPaths [] = \dirname ($ r ->getFileName ()).'/Resources/translations ' ;
1251
1246
}
1252
- if (ContainerBuilder::willBeAvailable ('symfony/form ' , Form::class, ['symfony/framework-bundle ' , 'symfony/translation ' ], true )) {
1247
+ if (ContainerBuilder::willBeAvailable ('symfony/form ' , Form::class, ['symfony/framework-bundle ' , 'symfony/translation ' ])) {
1253
1248
$ r = new \ReflectionClass (Form::class);
1254
1249
1255
1250
$ dirs [] = $ transPaths [] = \dirname ($ r ->getFileName ()).'/Resources/translations ' ;
1256
1251
}
1257
- if (ContainerBuilder::willBeAvailable ('symfony/security-core ' , AuthenticationException::class, ['symfony/framework-bundle ' , 'symfony/translation ' ], true )) {
1252
+ if (ContainerBuilder::willBeAvailable ('symfony/security-core ' , AuthenticationException::class, ['symfony/framework-bundle ' , 'symfony/translation ' ])) {
1258
1253
$ r = new \ReflectionClass (AuthenticationException::class);
1259
1254
1260
1255
$ dirs [] = $ transPaths [] = \dirname ($ r ->getFileName (), 2 ).'/Resources/translations ' ;
@@ -1359,7 +1354,7 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
1359
1354
foreach ($ classToServices as $ class => $ service ) {
1360
1355
$ package = substr ($ service , \strlen ('translation.provider_factory. ' ));
1361
1356
1362
- if (!$ container ->hasDefinition ('http_client ' ) || !ContainerBuilder::willBeAvailable (sprintf ('symfony/%s-translation-provider ' , $ package ), $ class , $ parentPackages, true )) {
1357
+ if (!$ container ->hasDefinition ('http_client ' ) || !ContainerBuilder::willBeAvailable (sprintf ('symfony/%s-translation-provider ' , $ package ), $ class , $ parentPackages )) {
1363
1358
$ container ->removeDefinition ($ service );
1364
1359
}
1365
1360
}
@@ -1474,7 +1469,7 @@ private function registerValidatorMapping(ContainerBuilder $container, array $co
1474
1469
$ files ['yaml ' === $ extension ? 'yml ' : $ extension ][] = $ path ;
1475
1470
};
1476
1471
1477
- if (ContainerBuilder::willBeAvailable ('symfony/form ' , Form::class, ['symfony/framework-bundle ' , 'symfony/validator ' ], true )) {
1472
+ if (ContainerBuilder::willBeAvailable ('symfony/form ' , Form::class, ['symfony/framework-bundle ' , 'symfony/validator ' ])) {
1478
1473
$ reflClass = new \ReflectionClass (Form::class);
1479
1474
$ fileRecorder ('xml ' , \dirname ($ reflClass ->getFileName ()).'/Resources/config/validation.xml ' );
1480
1475
}
@@ -1640,7 +1635,7 @@ private function registerSecretsConfiguration(array $config, ContainerBuilder $c
1640
1635
throw new InvalidArgumentException (sprintf ('Invalid value "%s" set as "decryption_env_var": only "word" characters are allowed. ' , $ config ['decryption_env_var ' ]));
1641
1636
}
1642
1637
1643
- if (ContainerBuilder::willBeAvailable ('symfony/string ' , LazyString::class, ['symfony/framework-bundle ' ], true )) {
1638
+ if (ContainerBuilder::willBeAvailable ('symfony/string ' , LazyString::class, ['symfony/framework-bundle ' ])) {
1644
1639
$ container ->getDefinition ('secrets.decryption_key ' )->replaceArgument (1 , $ config ['decryption_env_var ' ]);
1645
1640
} else {
1646
1641
$ container ->getDefinition ('secrets.vault ' )->replaceArgument (1 , "%env( {$ config ['decryption_env_var ' ]})% " );
@@ -1776,7 +1771,7 @@ private function registerPropertyInfoConfiguration(ContainerBuilder $container,
1776
1771
1777
1772
$ loader ->load ('property_info.php ' );
1778
1773
1779
- if (ContainerBuilder::willBeAvailable ('phpdocumentor/reflection-docblock ' , DocBlockFactoryInterface::class, ['symfony/framework-bundle ' , 'symfony/property-info ' ], true )) {
1774
+ if (ContainerBuilder::willBeAvailable ('phpdocumentor/reflection-docblock ' , DocBlockFactoryInterface::class, ['symfony/framework-bundle ' , 'symfony/property-info ' ])) {
1780
1775
$ definition = $ container ->register ('property_info.php_doc_extractor ' , 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor ' );
1781
1776
$ definition ->addTag ('property_info.description_extractor ' , ['priority ' => -1000 ]);
1782
1777
$ definition ->addTag ('property_info.type_extractor ' , ['priority ' => -1001 ]);
@@ -1847,19 +1842,19 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
1847
1842
1848
1843
$ loader ->load ('messenger.php ' );
1849
1844
1850
- if (ContainerBuilder::willBeAvailable ('symfony/amqp-messenger ' , AmqpTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/messenger ' ], true )) {
1845
+ if (ContainerBuilder::willBeAvailable ('symfony/amqp-messenger ' , AmqpTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/messenger ' ])) {
1851
1846
$ container ->getDefinition ('messenger.transport.amqp.factory ' )->addTag ('messenger.transport_factory ' );
1852
1847
}
1853
1848
1854
- if (ContainerBuilder::willBeAvailable ('symfony/redis-messenger ' , RedisTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/messenger ' ], true )) {
1849
+ if (ContainerBuilder::willBeAvailable ('symfony/redis-messenger ' , RedisTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/messenger ' ])) {
1855
1850
$ container ->getDefinition ('messenger.transport.redis.factory ' )->addTag ('messenger.transport_factory ' );
1856
1851
}
1857
1852
1858
- if (ContainerBuilder::willBeAvailable ('symfony/amazon-sqs-messenger ' , AmazonSqsTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/messenger ' ], true )) {
1853
+ if (ContainerBuilder::willBeAvailable ('symfony/amazon-sqs-messenger ' , AmazonSqsTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/messenger ' ])) {
1859
1854
$ container ->getDefinition ('messenger.transport.sqs.factory ' )->addTag ('messenger.transport_factory ' );
1860
1855
}
1861
1856
1862
- if (ContainerBuilder::willBeAvailable ('symfony/beanstalkd-messenger ' , BeanstalkdTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/messenger ' ], true )) {
1857
+ if (ContainerBuilder::willBeAvailable ('symfony/beanstalkd-messenger ' , BeanstalkdTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/messenger ' ])) {
1863
1858
$ container ->getDefinition ('messenger.transport.beanstalkd.factory ' )->addTag ('messenger.transport_factory ' );
1864
1859
}
1865
1860
@@ -2185,12 +2180,12 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
2185
2180
unset($ options ['retry_failed ' ]);
2186
2181
$ container ->getDefinition ('http_client ' )->setArguments ([$ options , $ config ['max_host_connections ' ] ?? 6 ]);
2187
2182
2188
- if (!$ hasPsr18 = ContainerBuilder::willBeAvailable ('psr/http-client ' , ClientInterface::class, ['symfony/framework-bundle ' , 'symfony/http-client ' ], true )) {
2183
+ if (!$ hasPsr18 = ContainerBuilder::willBeAvailable ('psr/http-client ' , ClientInterface::class, ['symfony/framework-bundle ' , 'symfony/http-client ' ])) {
2189
2184
$ container ->removeDefinition ('psr18.http_client ' );
2190
2185
$ container ->removeAlias (ClientInterface::class);
2191
2186
}
2192
2187
2193
- if (!ContainerBuilder::willBeAvailable ('php-http/httplug ' , HttpClient::class, ['symfony/framework-bundle ' , 'symfony/http-client ' ], true )) {
2188
+ if (!ContainerBuilder::willBeAvailable ('php-http/httplug ' , HttpClient::class, ['symfony/framework-bundle ' , 'symfony/http-client ' ])) {
2194
2189
$ container ->removeDefinition (HttpClient::class);
2195
2190
}
2196
2191
@@ -2320,7 +2315,7 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
2320
2315
foreach ($ classToServices as $ class => $ service ) {
2321
2316
$ package = substr ($ service , \strlen ('mailer.transport_factory. ' ));
2322
2317
2323
- if (!ContainerBuilder::willBeAvailable (sprintf ('symfony/%s-mailer ' , 'gmail ' === $ package ? 'google ' : $ package ), $ class , ['symfony/framework-bundle ' , 'symfony/mailer ' ], true )) {
2318
+ if (!ContainerBuilder::willBeAvailable (sprintf ('symfony/%s-mailer ' , 'gmail ' === $ package ? 'google ' : $ package ), $ class , ['symfony/framework-bundle ' , 'symfony/mailer ' ])) {
2324
2319
$ container ->removeDefinition ($ service );
2325
2320
}
2326
2321
}
@@ -2462,25 +2457,25 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
2462
2457
case 'turbosms ' : $ package = 'turbo-sms ' ; break ;
2463
2458
}
2464
2459
2465
- if (!ContainerBuilder::willBeAvailable (sprintf ('symfony/%s-notifier ' , $ package ), $ class , $ parentPackages, true )) {
2460
+ if (!ContainerBuilder::willBeAvailable (sprintf ('symfony/%s-notifier ' , $ package ), $ class , $ parentPackages )) {
2466
2461
$ container ->removeDefinition ($ service );
2467
2462
}
2468
2463
}
2469
2464
2470
- if (ContainerBuilder::willBeAvailable ('symfony/mercure-notifier ' , MercureTransportFactory::class, $ parentPackages, true ) && ContainerBuilder::willBeAvailable ('symfony/mercure-bundle ' , MercureBundle::class, $ parentPackages, true )) {
2465
+ if (ContainerBuilder::willBeAvailable ('symfony/mercure-notifier ' , MercureTransportFactory::class, $ parentPackages ) && ContainerBuilder::willBeAvailable ('symfony/mercure-bundle ' , MercureBundle::class, $ parentPackages )) {
2471
2466
$ container ->getDefinition ($ classToServices [MercureTransportFactory::class])
2472
2467
->replaceArgument ('$registry ' , new Reference (HubRegistry::class));
2473
- } elseif (ContainerBuilder::willBeAvailable ('symfony/mercure-notifier ' , MercureTransportFactory::class, $ parentPackages, true )) {
2468
+ } elseif (ContainerBuilder::willBeAvailable ('symfony/mercure-notifier ' , MercureTransportFactory::class, $ parentPackages )) {
2474
2469
$ container ->removeDefinition ($ classToServices [MercureTransportFactory::class]);
2475
2470
}
2476
2471
2477
- if (ContainerBuilder::willBeAvailable ('symfony/fake-chat-notifier ' , FakeChatTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/notifier ' , 'symfony/mailer ' ], true )) {
2472
+ if (ContainerBuilder::willBeAvailable ('symfony/fake-chat-notifier ' , FakeChatTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/notifier ' , 'symfony/mailer ' ])) {
2478
2473
$ container ->getDefinition ($ classToServices [FakeChatTransportFactory::class])
2479
2474
->replaceArgument ('$mailer ' , new Reference ('mailer ' ))
2480
2475
->replaceArgument ('$logger ' , new Reference ('logger ' ));
2481
2476
}
2482
2477
2483
- if (ContainerBuilder::willBeAvailable ('symfony/fake-sms-notifier ' , FakeSmsTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/notifier ' , 'symfony/mailer ' ], true )) {
2478
+ if (ContainerBuilder::willBeAvailable ('symfony/fake-sms-notifier ' , FakeSmsTransportFactory::class, ['symfony/framework-bundle ' , 'symfony/notifier ' , 'symfony/mailer ' ])) {
2484
2479
$ container ->getDefinition ($ classToServices [FakeSmsTransportFactory::class])
2485
2480
->replaceArgument ('$mailer ' , new Reference ('mailer ' ))
2486
2481
->replaceArgument ('$logger ' , new Reference ('logger ' ));
0 commit comments