Skip to content

Commit be0f5ff

Browse files
committed
[HttpKernel] remove all deprecated code from http kernel
1 parent d2909ca commit be0f5ff

File tree

59 files changed

+331
-956
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+331
-956
lines changed

UPGRADE-5.0.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ HttpKernel
252252
----------
253253

254254
* Removed `Client`, use `HttpKernelBrowser` instead
255-
* The `Kernel::getRootDir()` and the `kernel.root_dir` parameter have been removed
255+
* The `Kernel::getRootDir()` and the `kernel.root_dir` parameter
256+
have been removed, use `Kernel::getProjectDir()` and the `kernel.project_dir` instead
256257
* The `KernelInterface::getName()` and the `kernel.name` parameter have been removed
257258
* Removed the first and second constructor argument of `ConfigDataCollector`
258259
* Removed `ConfigDataCollector::getApplicationName()`
@@ -265,6 +266,7 @@ HttpKernel
265266
* Removed `GetResponseForExceptionEvent`, use `ExceptionEvent` instead
266267
* Removed `PostResponseEvent`, use `TerminateEvent` instead
267268
* Removed `TranslatorListener` in favor of `LocaleAwareListener`
269+
* Removed `SaveSessionListener` in favor of `AbstractSessionListener`
268270
* The `DebugHandlersListener` class has been made `final`
269271

270272
Intl

src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Monolog\Handler\ChromePHPHandler as BaseChromePhpHandler;
1515
use Symfony\Component\HttpFoundation\Response;
16-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
16+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
1717

1818
/**
1919
* ChromePhpHandler.
@@ -34,7 +34,7 @@ class ChromePhpHandler extends BaseChromePhpHandler
3434
/**
3535
* Adds the headers to the response once it's created.
3636
*/
37-
public function onKernelResponse(FilterResponseEvent $event)
37+
public function onKernelResponse(ResponseEvent $event)
3838
{
3939
if (!$event->isMasterRequest()) {
4040
return;

src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Monolog\Handler\FirePHPHandler as BaseFirePHPHandler;
1515
use Symfony\Component\HttpFoundation\Response;
16-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
16+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
1717

1818
/**
1919
* FirePHPHandler.
@@ -34,7 +34,7 @@ class FirePHPHandler extends BaseFirePHPHandler
3434
/**
3535
* Adds the headers to the response once it's created.
3636
*/
37-
public function onKernelResponse(FilterResponseEvent $event)
37+
public function onKernelResponse(ResponseEvent $event)
3838
{
3939
if (!$event->isMasterRequest()) {
4040
return;

src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Monolog\Handler\SwiftMailerHandler as BaseSwiftMailerHandler;
1515
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
16-
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
16+
use Symfony\Component\HttpKernel\Event\TerminateEvent;
1717

1818
/**
1919
* Extended SwiftMailerHandler that flushes mail queue if necessary.
@@ -36,7 +36,7 @@ public function setTransport(\Swift_Transport $transport)
3636
/**
3737
* After the kernel has been terminated we will always flush messages.
3838
*/
39-
public function onKernelTerminate(PostResponseEvent $event)
39+
public function onKernelTerminate(TerminateEvent $event)
4040
{
4141
$this->instantFlush = true;
4242
}

src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1515
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
16-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
16+
use Symfony\Component\HttpKernel\Event\RequestEvent;
1717
use Symfony\Component\HttpKernel\KernelEvents;
1818
use Symfony\Contracts\Service\ResetInterface;
1919

@@ -49,7 +49,7 @@ public function reset()
4949
$this->routeData = [];
5050
}
5151

52-
public function addRouteData(GetResponseEvent $event)
52+
public function addRouteData(RequestEvent $event)
5353
{
5454
if ($event->isMasterRequest()) {
5555
$this->reset();

src/Symfony/Bridge/Monolog/Processor/WebProcessor.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Monolog\Processor\WebProcessor as BaseWebProcessor;
1515
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
16-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
16+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
1717
use Symfony\Component\HttpKernel\KernelEvents;
1818

1919
/**
@@ -31,7 +31,7 @@ public function __construct(array $extraFields = null)
3131
parent::__construct([], $extraFields);
3232
}
3333

34-
public function onKernelRequest(GetResponseEvent $event)
34+
public function onKernelRequest(ResponseEvent $event)
3535
{
3636
if ($event->isMasterRequest()) {
3737
$this->serverData = $event->getRequest()->server->all();

src/Symfony/Bridge/Monolog/Tests/Processor/RouteProcessorTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\HttpFoundation\ParameterBag;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
19-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
19+
use Symfony\Component\HttpKernel\Event\RequestEvent;
2020

2121
class RouteProcessorTest extends TestCase
2222
{
@@ -122,9 +122,9 @@ public function testProcessorDoesNothingWhenNoRequest()
122122
$this->assertEquals(['extra' => []], $record);
123123
}
124124

125-
private function mockGetResponseEvent(Request $request): GetResponseEvent
125+
private function mockGetResponseEvent(Request $request): RequestEvent
126126
{
127-
$event = $this->getMockBuilder(GetResponseEvent::class)->disableOriginalConstructor()->getMock();
127+
$event = $this->getMockBuilder(RequestEvent::class)->disableOriginalConstructor()->getMock();
128128
$event->method('getRequest')->willReturn($request);
129129

130130
return $event;

src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\Bridge\Monolog\Processor\WebProcessor;
1717
use Symfony\Component\HttpFoundation\Request;
18-
use Symfony\Component\HttpKernel\Event\RequestEvent;
18+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
1919

2020
class WebProcessorTest extends TestCase
2121
{
@@ -88,7 +88,7 @@ private function createRequestEvent($additionalServerParameters = []): array
8888
$request->server->replace($server);
8989
$request->headers->replace($server);
9090

91-
$event = $this->getMockBuilder(RequestEvent::class)
91+
$event = $this->getMockBuilder(ResponseEvent::class)
9292
->disableOriginalConstructor()
9393
->getMock();
9494
$event->expects($this->any())

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@
8787

8888
<service id="file_locator" class="Symfony\Component\HttpKernel\Config\FileLocator">
8989
<argument type="service" id="kernel" />
90-
<argument>%kernel.root_dir%/Resources</argument>
90+
<argument>%kernel.project_dir%/Resources</argument>
9191
<argument type="collection">
92-
<argument>%kernel.root_dir%</argument>
92+
<argument>%kernel.project_dir%</argument>
9393
</argument>
9494
</service>
9595
<service id="Symfony\Component\HttpKernel\Config\FileLocator" alias="file_locator" />

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function ($path, $catalogue) use ($loadedMessages) {
176176
->willReturn([]);
177177

178178
$container = new Container();
179-
$container->setParameter('kernel.root_dir', $this->translationDir);
179+
$container->setParameter('kernel.project_dir', $this->translationDir);
180180

181181
$kernel
182182
->expects($this->any())

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function ($path, $catalogue) use ($loadedMessages) {
159159

160160
$kernel
161161
->expects($this->any())
162-
->method('getRootDir')
162+
->method('getProjectDir')
163163
->willReturn($this->translationDir);
164164

165165
$kernel
@@ -168,7 +168,7 @@ function ($path, $catalogue) use ($loadedMessages) {
168168
->willReturn([]);
169169

170170
$container = new Container();
171-
$container->setParameter('kernel.root_dir', $this->translationDir);
171+
$container->setParameter('kernel.project_dir', $this->translationDir);
172172
$kernel
173173
->expects($this->any())
174174
->method('getContainer')

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,6 @@ protected function createContainer(array $data = [])
14421442
'kernel.debug' => false,
14431443
'kernel.environment' => 'test',
14441444
'kernel.name' => 'kernel',
1445-
'kernel.root_dir' => __DIR__,
14461445
'kernel.container_class' => 'testContainer',
14471446
'container.build_hash' => 'Abc1234',
14481447
'container.build_id' => hash('crc32', 'Abc123423456789'),

src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
2020
use Symfony\Component\Filesystem\Filesystem;
2121
use Symfony\Component\HttpFoundation\Response;
22-
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
22+
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
2323
use Symfony\Component\HttpKernel\Kernel;
2424
use Symfony\Component\HttpKernel\KernelEvents;
2525
use Symfony\Component\Routing\RouteCollectionBuilder;
@@ -30,7 +30,7 @@ class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface
3030

3131
private $cacheDir;
3232

33-
public function onKernelException(GetResponseForExceptionEvent $event)
33+
public function onKernelException(ExceptionEvent $event)
3434
{
3535
if ($event->getException() instanceof Danger) {
3636
$event->setResponse(Response::create('It\'s dangerous to go alone. Take this ⚔'));

src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
1515
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1616
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
17-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
17+
use Symfony\Component\HttpKernel\Event\RequestEvent;
1818
use Symfony\Component\HttpKernel\KernelEvents;
1919
use Symfony\Component\Security\Http\Firewall;
2020
use Symfony\Component\Security\Http\FirewallMapInterface;
@@ -41,7 +41,7 @@ public function __construct(FirewallMapInterface $map, EventDispatcherInterface
4141
/**
4242
* @internal
4343
*/
44-
public function configureLogoutUrlGenerator(GetResponseEvent $event)
44+
public function configureLogoutUrlGenerator(RequestEvent $event)
4545
{
4646
if (!$event->isMasterRequest()) {
4747
return;

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ private function createContainer($sessionStorageOptions)
125125
$container->setParameter('kernel.container_class', 'cc');
126126
$container->setParameter('kernel.debug', true);
127127
$container->setParameter('kernel.project_dir', __DIR__);
128-
$container->setParameter('kernel.root_dir', __DIR__);
129128
$container->setParameter('kernel.secret', __DIR__);
130129
if (null !== $sessionStorageOptions) {
131130
$container->setParameter('session.storage.options', $sessionStorageOptions);

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ public function testRememberMeCookieInheritFrameworkSessionCookie($config, $same
354354
$container->registerExtension(new FrameworkExtension());
355355
$container->setParameter('kernel.bundles_metadata', []);
356356
$container->setParameter('kernel.project_dir', __DIR__);
357-
$container->setParameter('kernel.root_dir', __DIR__);
358357
$container->setParameter('kernel.cache_dir', __DIR__);
359358

360359
$container->loadFromExtension('security', [

src/Symfony/Bundle/TwigBundle/Resources/config/console.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<argument>%kernel.bundles_metadata%</argument>
1414
<argument>%twig.default_path%</argument>
1515
<argument type="service" id="debug.file_link_formatter" on-invalid="null" />
16-
<argument>%kernel.root_dir%</argument>
16+
<argument>%kernel.project_dir%</argument>
1717
<tag name="console.command" command="debug:twig" />
1818
</service>
1919

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ private function createContainer(string $rootDir = __DIR__.'/Fixtures')
264264
{
265265
$container = new ContainerBuilder(new ParameterBag([
266266
'kernel.cache_dir' => __DIR__,
267-
'kernel.root_dir' => $rootDir,
268267
'kernel.project_dir' => __DIR__,
269268
'kernel.charset' => 'UTF-8',
270269
'kernel.debug' => false,

src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
1818
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
19-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
19+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
2020
use Symfony\Component\HttpKernel\KernelEvents;
2121
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2222
use Twig\Environment;
@@ -60,7 +60,7 @@ public function isEnabled()
6060
return self::DISABLED !== $this->mode;
6161
}
6262

63-
public function onKernelResponse(FilterResponseEvent $event)
63+
public function onKernelResponse(ResponseEvent $event)
6464
{
6565
$response = $event->getResponse();
6666
$request = $event->getRequest();

src/Symfony/Component/HttpKernel/CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ CHANGELOG
88
* removed `ConfigDataCollector::getApplicationName()`
99
* removed `ConfigDataCollector::getApplicationVersion()`
1010
* removed support for `Symfony\Component\Templating\EngineInterface` in `HIncludeFragmentRenderer`, use a `Twig\Environment` only
11+
* removed `Client`, use `HttpKernelBrowser` instead
12+
* removed the `Kernel::getRootDir()` and the `kernel.root_dir` parameter
13+
* removed the `KernelInterface::getName()` and the `kernel.name` parameter
14+
* removed the first and second constructor argument of `ConfigDataCollector`
15+
* removed `ConfigDataCollector::getApplicationName()`
16+
* removed `ConfigDataCollector::getApplicationVersion()`
17+
* removed `FilterControllerArgumentsEvent`, use `ControllerArgumentsEvent` instead
18+
* removed `FilterControllerEvent`, use `ControllerEvent` instead
19+
* removed `FilterResponseEvent`, use `ResponseEvent` instead
20+
* removed `GetResponseEvent`, use `RequestEvent` instead
21+
* removed `GetResponseForControllerResultEvent`, use `ViewEvent` instead
22+
* removed `GetResponseForExceptionEvent`, use `ExceptionEvent` instead
23+
* removed `PostResponseEvent`, use `TerminateEvent` instead
24+
* removed `TranslatorListener` in favor of `LocaleAwareListener`
25+
* removed `SaveSessionListener` in favor of `AbstractSessionListener`
1126

1227
4.3.0
1328
-----

src/Symfony/Component/HttpKernel/Client.php

-18
This file was deleted.

src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php

-14
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,6 @@ public function getPhpTimezone()
211211
return $this->data['php_timezone'];
212212
}
213213

214-
/**
215-
* Gets the application name.
216-
*
217-
* @return string The application name
218-
*
219-
* @deprecated since Symfony 4.2
220-
*/
221-
public function getAppName()
222-
{
223-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
224-
225-
return 'n/a';
226-
}
227-
228214
/**
229215
* Gets the environment.
230216
*

src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
use Symfony\Component\HttpFoundation\ParameterBag;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\HttpFoundation\Response;
19-
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
20-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
19+
use Symfony\Component\HttpKernel\Event\ControllerEvent;
20+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
2121
use Symfony\Component\HttpKernel\KernelEvents;
2222

2323
/**
@@ -353,15 +353,15 @@ public function getForwardToken()
353353
/**
354354
* @final since Symfony 4.3
355355
*/
356-
public function onKernelController(FilterControllerEvent $event)
356+
public function onKernelController(ControllerEvent $event)
357357
{
358358
$this->controllers[$event->getRequest()] = $event->getController();
359359
}
360360

361361
/**
362362
* @final since Symfony 4.3
363363
*/
364-
public function onKernelResponse(FilterResponseEvent $event)
364+
public function onKernelResponse(ResponseEvent $event)
365365
{
366366
if (!$event->isMasterRequest()) {
367367
return;

src/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\HttpFoundation\RedirectResponse;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Response;
17-
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
17+
use Symfony\Component\HttpKernel\Event\ControllerEvent;
1818

1919
/**
2020
* @author Fabien Potencier <fabien@symfony.com>
@@ -69,7 +69,7 @@ protected function guessRoute(Request $request, $controller)
6969
*
7070
* @final since Symfony 4.3
7171
*/
72-
public function onKernelController(FilterControllerEvent $event)
72+
public function onKernelController(ControllerEvent $event)
7373
{
7474
$this->controllers[$event->getRequest()] = $event->getController();
7575
}

0 commit comments

Comments
 (0)