Skip to content

Commit 53a6169

Browse files
[FrameworkBundle] dont access the container to configure http_cache
1 parent 8889da1 commit 53a6169

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public function load(array $configs, ContainerBuilder $container)
392392

393393
$propertyInfoEnabled = $this->isConfigEnabled($container, $config['property_info']);
394394
$this->registerValidationConfiguration($config['validation'], $container, $loader, $propertyInfoEnabled);
395-
$this->registerHttpCacheConfiguration($config['http_cache'], $container);
395+
$this->registerHttpCacheConfiguration($config['http_cache'], $container, $config['http_method_override']);
396396
$this->registerEsiConfiguration($config['esi'], $container, $loader);
397397
$this->registerSsiConfiguration($config['ssi'], $container, $loader);
398398
$this->registerFragmentsConfiguration($config['fragments'], $container, $loader);
@@ -580,7 +580,7 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont
580580
}
581581
}
582582

583-
private function registerHttpCacheConfiguration(array $config, ContainerBuilder $container)
583+
private function registerHttpCacheConfiguration(array $config, ContainerBuilder $container, bool $httpMethodOverride)
584584
{
585585
$options = $config;
586586
unset($options['enabled']);
@@ -592,6 +592,13 @@ private function registerHttpCacheConfiguration(array $config, ContainerBuilder
592592
$container->getDefinition('http_cache')
593593
->setPublic($config['enabled'])
594594
->replaceArgument(3, $options);
595+
596+
if ($httpMethodOverride) {
597+
$container->getDefinition('http_cache')
598+
->addArgument((new Definition('void'))
599+
->setFactory([Request::class, 'enableHttpMethodParameterOverride'])
600+
);
601+
}
595602
}
596603

597604
private function registerEsiConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader)

HttpCache/HttpCache.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Symfony\Component\HttpKernel\HttpCache\Store;
1919
use Symfony\Component\HttpKernel\HttpCache\StoreInterface;
2020
use Symfony\Component\HttpKernel\HttpCache\SurrogateInterface;
21-
use Symfony\Component\HttpKernel\HttpKernelInterface;
2221
use Symfony\Component\HttpKernel\KernelInterface;
2322

2423
/**
@@ -63,15 +62,6 @@ public function __construct(KernelInterface $kernel, $cache = null, SurrogateInt
6362
parent::__construct($kernel, $this->createStore(), $this->createSurrogate(), array_merge($this->options, $this->getOptions()));
6463
}
6564

66-
public function handle(Request $request, int $type = HttpKernelInterface::MASTER_REQUEST, bool $catch = true)
67-
{
68-
if ($this->kernel->getContainer()->getParameter('kernel.http_method_override')) {
69-
Request::enableHttpMethodParameterOverride();
70-
}
71-
72-
return parent::handle($request, $type, $catch);
73-
}
74-
7565
/**
7666
* {@inheritdoc}
7767
*/

0 commit comments

Comments
 (0)