Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f73384a

Browse filesBrowse files
committed
[FrameworkBundle] Remove obsolete feature detection
1 parent 1f257d3 commit f73384a
Copy full SHA for f73384a

File tree

1 file changed

+21
-75
lines changed
Filter options

1 file changed

+21
-75
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+21-75Lines changed: 21 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
use Symfony\Component\Cache\Adapter\ChainAdapter;
4242
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
4343
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
44-
use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
4544
use Symfony\Component\Cache\Marshaller\MarshallerInterface;
4645
use Symfony\Component\Cache\ResettableInterface;
4746
use Symfony\Component\Clock\ClockInterface;
@@ -75,7 +74,6 @@
7574
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
7675
use Symfony\Component\Finder\Finder;
7776
use Symfony\Component\Finder\Glob;
78-
use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
7977
use Symfony\Component\Form\Extension\HtmlSanitizer\Type\TextTypeHtmlSanitizerExtension;
8078
use Symfony\Component\Form\Form;
8179
use Symfony\Component\Form\FormTypeExtensionInterface;
@@ -95,8 +93,6 @@
9593
use Symfony\Component\HttpKernel\Attribute\AsTargetedValueResolver;
9694
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
9795
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
98-
use Symfony\Component\HttpKernel\Controller\ArgumentResolver\BackedEnumValueResolver;
99-
use Symfony\Component\HttpKernel\Controller\ArgumentResolver\UidValueResolver;
10096
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
10197
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
10298
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
@@ -113,7 +109,6 @@
113109
use Symfony\Component\Mercure\HubRegistry;
114110
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
115111
use Symfony\Component\Messenger\Bridge as MessengerBridge;
116-
use Symfony\Component\Messenger\Command\StatsCommand;
117112
use Symfony\Component\Messenger\EventListener\StopWorkerOnSignalsListener;
118113
use Symfony\Component\Messenger\Handler\BatchHandlerInterface;
119114
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
@@ -150,7 +145,6 @@
150145
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
151146
use Symfony\Component\RemoteEvent\RemoteEvent;
152147
use Symfony\Component\Routing\Loader\AnnotationClassLoader;
153-
use Symfony\Component\Routing\Loader\Psr4DirectoryLoader;
154148
use Symfony\Component\Scheduler\Attribute\AsSchedule;
155149
use Symfony\Component\Scheduler\Messenger\SchedulerTransportFactory;
156150
use Symfony\Component\Security\Core\AuthenticationEvents;
@@ -167,10 +161,7 @@
167161
use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
168162
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
169163
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
170-
use Symfony\Component\Serializer\Normalizer\ProblemNormalizer;
171-
use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer;
172164
use Symfony\Component\Serializer\Serializer;
173-
use Symfony\Component\Serializer\SerializerAwareInterface;
174165
use Symfony\Component\Stopwatch\Stopwatch;
175166
use Symfony\Component\String\LazyString;
176167
use Symfony\Component\String\Slugger\SluggerInterface;
@@ -182,7 +173,6 @@
182173
use Symfony\Component\Translation\Translator;
183174
use Symfony\Component\Uid\Factory\UuidFactory;
184175
use Symfony\Component\Uid\UuidV4;
185-
use Symfony\Component\Validator\Constraints\WhenValidator;
186176
use Symfony\Component\Validator\ConstraintValidatorInterface;
187177
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
188178
use Symfony\Component\Validator\ObjectInitializerInterface;
@@ -227,11 +217,6 @@ public function load(array $configs, ContainerBuilder $container)
227217
}
228218

229219
$loader->load('web.php');
230-
231-
if (!class_exists(BackedEnumValueResolver::class)) {
232-
$container->removeDefinition('argument_resolver.backed_enum_resolver');
233-
}
234-
235220
$loader->load('services.php');
236221
$loader->load('fragment_renderer.php');
237222
$loader->load('error_renderer.php');
@@ -775,11 +760,6 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont
775760
if (!ContainerBuilder::willBeAvailable('symfony/translation', Translator::class, ['symfony/framework-bundle', 'symfony/form'])) {
776761
$container->removeDefinition('form.type_extension.upload.validator');
777762
}
778-
if (!method_exists(CachingFactoryDecorator::class, 'reset')) {
779-
$container->getDefinition('form.choice_list_factory.cached')
780-
->clearTag('kernel.reset')
781-
;
782-
}
783763
}
784764

785765
private function registerHttpCacheConfiguration(array $config, ContainerBuilder $container, bool $httpMethodOverride): void
@@ -1219,10 +1199,6 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
12191199
->replaceArgument(0, $config['default_uri']);
12201200
}
12211201

1222-
if (!class_exists(Psr4DirectoryLoader::class)) {
1223-
$container->removeDefinition('routing.loader.psr4');
1224-
}
1225-
12261202
if ($this->isInitializedConfigEnabled('annotations') && (new \ReflectionClass(AnnotationClassLoader::class))->hasProperty('reader')) {
12271203
$container->getDefinition('routing.loader.annotation')->setArguments([
12281204
new Reference('annotation_reader'),
@@ -1688,10 +1664,6 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
16881664
if (!class_exists(ExpressionLanguage::class)) {
16891665
$container->removeDefinition('validator.expression_language');
16901666
}
1691-
1692-
if (!class_exists(WhenValidator::class)) {
1693-
$container->removeDefinition('validator.when');
1694-
}
16951667
}
16961668

16971669
private function registerValidatorMapping(ContainerBuilder $container, array $config, array &$files): void
@@ -1911,7 +1883,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
19111883
$container->removeDefinition('serializer.encoder.yaml');
19121884
}
19131885

1914-
if (!class_exists(UnwrappingDenormalizer::class) || !$this->isInitializedConfigEnabled('property_access')) {
1886+
if (!$this->isInitializedConfigEnabled('property_access')) {
19151887
$container->removeDefinition('serializer.denormalizer.unwrapping');
19161888
}
19171889

@@ -1923,12 +1895,6 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
19231895
$container->removeDefinition('serializer.normalizer.translatable');
19241896
}
19251897

1926-
// compat with Symfony < 6.3
1927-
if (!is_subclass_of(ProblemNormalizer::class, SerializerAwareInterface::class)) {
1928-
$container->getDefinition('serializer.normalizer.problem')
1929-
->setArguments(['%kernel.debug%']);
1930-
}
1931-
19321898
$serializerLoaders = [];
19331899
if (isset($config['enable_attributes']) && $config['enable_attributes']) {
19341900
if ($container->getParameter('kernel.debug')) {
@@ -2125,7 +2091,7 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
21252091
throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
21262092
}
21272093

2128-
if (!$this->hasConsole() || !class_exists(StatsCommand::class)) {
2094+
if (!$this->hasConsole()) {
21292095
$container->removeDefinition('console.command.messenger_stats');
21302096
}
21312097

@@ -2370,10 +2336,6 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
23702336

23712337
private function registerCacheConfiguration(array $config, ContainerBuilder $container): void
23722338
{
2373-
if (!class_exists(DefaultMarshaller::class)) {
2374-
$container->removeDefinition('cache.default_marshaller');
2375-
}
2376-
23772339
$version = new Parameter('container.build_id');
23782340
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
23792341
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
@@ -2434,16 +2396,10 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
24342396
$container->register($name, TagAwareAdapter::class)
24352397
->addArgument(new Reference('.'.$name.'.inner'))
24362398
->addArgument(true !== $pool['tags'] ? new Reference($pool['tags']) : null)
2399+
->addMethodCall('setLogger', [new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)])
24372400
->setPublic($pool['public'])
24382401
->addTag('cache.taggable', ['pool' => $name])
2439-
;
2440-
2441-
if (method_exists(TagAwareAdapter::class, 'setLogger')) {
2442-
$container
2443-
->getDefinition($name)
2444-
->addMethodCall('setLogger', [new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)])
2445-
->addTag('monolog.logger', ['channel' => 'cache']);
2446-
}
2402+
->addTag('monolog.logger', ['channel' => 'cache']);
24472403

24482404
$pool['name'] = $tagAwareId = $name;
24492405
$pool['public'] = false;
@@ -2469,7 +2425,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
24692425
$container->setDefinition($name, $definition);
24702426
}
24712427

2472-
if (method_exists(PropertyAccessor::class, 'createCache')) {
2428+
if (class_exists(PropertyAccessor::class)) {
24732429
$propertyAccessDefinition = $container->register('cache.property_access', AdapterInterface::class);
24742430

24752431
if (!$container->getParameter('kernel.debug')) {
@@ -2514,20 +2470,16 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
25142470
$this->registerRetryableHttpClient($retryOptions, 'http_client', $container);
25152471
}
25162472

2517-
if ($hasUriTemplate = class_exists(UriTemplateHttpClient::class)) {
2518-
if (ContainerBuilder::willBeAvailable('guzzlehttp/uri-template', \GuzzleHttp\UriTemplate\UriTemplate::class, [])) {
2519-
$container->setAlias('http_client.uri_template_expander', 'http_client.uri_template_expander.guzzle');
2520-
} elseif (ContainerBuilder::willBeAvailable('rize/uri-template', \Rize\UriTemplate::class, [])) {
2521-
$container->setAlias('http_client.uri_template_expander', 'http_client.uri_template_expander.rize');
2522-
}
2523-
2524-
$container
2525-
->getDefinition('http_client.uri_template')
2526-
->setArgument(2, $defaultUriTemplateVars);
2527-
} elseif ($defaultUriTemplateVars) {
2528-
throw new LogicException('Support for URI template requires symfony/http-client 6.3 or higher, try upgrading.');
2473+
if (ContainerBuilder::willBeAvailable('guzzlehttp/uri-template', \GuzzleHttp\UriTemplate\UriTemplate::class, [])) {
2474+
$container->setAlias('http_client.uri_template_expander', 'http_client.uri_template_expander.guzzle');
2475+
} elseif (ContainerBuilder::willBeAvailable('rize/uri-template', \Rize\UriTemplate::class, [])) {
2476+
$container->setAlias('http_client.uri_template_expander', 'http_client.uri_template_expander.rize');
25292477
}
25302478

2479+
$container
2480+
->getDefinition('http_client.uri_template')
2481+
->setArgument(2, $defaultUriTemplateVars);
2482+
25312483
foreach ($config['scoped_clients'] as $name => $scopeConfig) {
25322484
if ($container->has($name)) {
25332485
throw new InvalidArgumentException(sprintf('Invalid scope name: "%s" is reserved.', $name));
@@ -2558,16 +2510,14 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
25582510
$this->registerRetryableHttpClient($retryOptions, $name, $container);
25592511
}
25602512

2561-
if ($hasUriTemplate) {
2562-
$container
2563-
->register($name.'.uri_template', UriTemplateHttpClient::class)
2564-
->setDecoratedService($name, null, 7) // Between TraceableHttpClient (5) and RetryableHttpClient (10)
2565-
->setArguments([
2566-
new Reference($name.'.uri_template.inner'),
2567-
new Reference('http_client.uri_template_expander', ContainerInterface::NULL_ON_INVALID_REFERENCE),
2568-
$defaultUriTemplateVars,
2569-
]);
2570-
}
2513+
$container
2514+
->register($name.'.uri_template', UriTemplateHttpClient::class)
2515+
->setDecoratedService($name, null, 7) // Between TraceableHttpClient (5) and RetryableHttpClient (10)
2516+
->setArguments([
2517+
new Reference($name.'.uri_template.inner'),
2518+
new Reference('http_client.uri_template_expander', ContainerInterface::NULL_ON_INVALID_REFERENCE),
2519+
$defaultUriTemplateVars,
2520+
]);
25712521

25722522
$container->registerAliasForArgument($name, HttpClientInterface::class);
25732523

@@ -3021,10 +2971,6 @@ private function registerUidConfiguration(array $config, ContainerBuilder $conta
30212971
$container->getDefinition('name_based_uuid.factory')
30222972
->setArguments([$config['name_based_uuid_namespace']]);
30232973
}
3024-
3025-
if (!class_exists(UidValueResolver::class)) {
3026-
$container->removeDefinition('argument_resolver.uid');
3027-
}
30282974
}
30292975

30302976
private function registerHtmlSanitizerConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.