Skip to content

Commit

Permalink
[HttpKernel] remove all deprecated code from http kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
Simperfit committed Jun 5, 2019
1 parent d2909ca commit be0f5ff
Show file tree
Hide file tree
Showing 59 changed files with 331 additions and 956 deletions.
4 changes: 3 additions & 1 deletion UPGRADE-5.0.md
Expand Up @@ -252,7 +252,8 @@ HttpKernel
----------

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

Intl
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php
Expand Up @@ -13,7 +13,7 @@

use Monolog\Handler\ChromePHPHandler as BaseChromePhpHandler;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;

/**
* ChromePhpHandler.
Expand All @@ -34,7 +34,7 @@ class ChromePhpHandler extends BaseChromePhpHandler
/**
* Adds the headers to the response once it's created.
*/
public function onKernelResponse(FilterResponseEvent $event)
public function onKernelResponse(ResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php
Expand Up @@ -13,7 +13,7 @@

use Monolog\Handler\FirePHPHandler as BaseFirePHPHandler;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;

/**
* FirePHPHandler.
Expand All @@ -34,7 +34,7 @@ class FirePHPHandler extends BaseFirePHPHandler
/**
* Adds the headers to the response once it's created.
*/
public function onKernelResponse(FilterResponseEvent $event)
public function onKernelResponse(ResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php
Expand Up @@ -13,7 +13,7 @@

use Monolog\Handler\SwiftMailerHandler as BaseSwiftMailerHandler;
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
use Symfony\Component\HttpKernel\Event\TerminateEvent;

/**
* Extended SwiftMailerHandler that flushes mail queue if necessary.
Expand All @@ -36,7 +36,7 @@ public function setTransport(\Swift_Transport $transport)
/**
* After the kernel has been terminated we will always flush messages.
*/
public function onKernelTerminate(PostResponseEvent $event)
public function onKernelTerminate(TerminateEvent $event)
{
$this->instantFlush = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php
Expand Up @@ -13,7 +13,7 @@

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Contracts\Service\ResetInterface;

Expand Down Expand Up @@ -49,7 +49,7 @@ public function reset()
$this->routeData = [];
}

public function addRouteData(GetResponseEvent $event)
public function addRouteData(RequestEvent $event)
{
if ($event->isMasterRequest()) {
$this->reset();
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Monolog/Processor/WebProcessor.php
Expand Up @@ -13,7 +13,7 @@

use Monolog\Processor\WebProcessor as BaseWebProcessor;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

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

public function onKernelRequest(GetResponseEvent $event)
public function onKernelRequest(ResponseEvent $event)
{
if ($event->isMasterRequest()) {
$this->serverData = $event->getRequest()->server->all();
Expand Down
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;

class RouteProcessorTest extends TestCase
{
Expand Down Expand Up @@ -122,9 +122,9 @@ public function testProcessorDoesNothingWhenNoRequest()
$this->assertEquals(['extra' => []], $record);
}

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

return $event;
Expand Down
Expand Up @@ -15,7 +15,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Monolog\Processor\WebProcessor;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;

class WebProcessorTest extends TestCase
{
Expand Down Expand Up @@ -88,7 +88,7 @@ private function createRequestEvent($additionalServerParameters = []): array
$request->server->replace($server);
$request->headers->replace($server);

$event = $this->getMockBuilder(RequestEvent::class)
$event = $this->getMockBuilder(ResponseEvent::class)
->disableOriginalConstructor()
->getMock();
$event->expects($this->any())
Expand Down
Expand Up @@ -87,9 +87,9 @@

<service id="file_locator" class="Symfony\Component\HttpKernel\Config\FileLocator">
<argument type="service" id="kernel" />
<argument>%kernel.root_dir%/Resources</argument>
<argument>%kernel.project_dir%/Resources</argument>
<argument type="collection">
<argument>%kernel.root_dir%</argument>
<argument>%kernel.project_dir%</argument>
</argument>
</service>
<service id="Symfony\Component\HttpKernel\Config\FileLocator" alias="file_locator" />
Expand Down
Expand Up @@ -176,7 +176,7 @@ function ($path, $catalogue) use ($loadedMessages) {
->willReturn([]);

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

$kernel
->expects($this->any())
Expand Down
Expand Up @@ -159,7 +159,7 @@ function ($path, $catalogue) use ($loadedMessages) {

$kernel
->expects($this->any())
->method('getRootDir')
->method('getProjectDir')
->willReturn($this->translationDir);

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

$container = new Container();
$container->setParameter('kernel.root_dir', $this->translationDir);
$container->setParameter('kernel.project_dir', $this->translationDir);
$kernel
->expects($this->any())
->method('getContainer')
Expand Down
Expand Up @@ -1442,7 +1442,6 @@ protected function createContainer(array $data = [])
'kernel.debug' => false,
'kernel.environment' => 'test',
'kernel.name' => 'kernel',
'kernel.root_dir' => __DIR__,
'kernel.container_class' => 'testContainer',
'container.build_hash' => 'Abc1234',
'container.build_id' => hash('crc32', 'Abc123423456789'),
Expand Down
Expand Up @@ -19,7 +19,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\RouteCollectionBuilder;
Expand All @@ -30,7 +30,7 @@ class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface

private $cacheDir;

public function onKernelException(GetResponseForExceptionEvent $event)
public function onKernelException(ExceptionEvent $event)
{
if ($event->getException() instanceof Danger) {
$event->setResponse(Response::create('It\'s dangerous to go alone. Take this ⚔'));
Expand Down
Expand Up @@ -14,7 +14,7 @@
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Http\Firewall;
use Symfony\Component\Security\Http\FirewallMapInterface;
Expand All @@ -41,7 +41,7 @@ public function __construct(FirewallMapInterface $map, EventDispatcherInterface
/**
* @internal
*/
public function configureLogoutUrlGenerator(GetResponseEvent $event)
public function configureLogoutUrlGenerator(RequestEvent $event)
{
if (!$event->isMasterRequest()) {
return;
Expand Down
Expand Up @@ -125,7 +125,6 @@ private function createContainer($sessionStorageOptions)
$container->setParameter('kernel.container_class', 'cc');
$container->setParameter('kernel.debug', true);
$container->setParameter('kernel.project_dir', __DIR__);
$container->setParameter('kernel.root_dir', __DIR__);
$container->setParameter('kernel.secret', __DIR__);
if (null !== $sessionStorageOptions) {
$container->setParameter('session.storage.options', $sessionStorageOptions);
Expand Down
Expand Up @@ -354,7 +354,6 @@ public function testRememberMeCookieInheritFrameworkSessionCookie($config, $same
$container->registerExtension(new FrameworkExtension());
$container->setParameter('kernel.bundles_metadata', []);
$container->setParameter('kernel.project_dir', __DIR__);
$container->setParameter('kernel.root_dir', __DIR__);
$container->setParameter('kernel.cache_dir', __DIR__);

$container->loadFromExtension('security', [
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/Resources/config/console.xml
Expand Up @@ -13,7 +13,7 @@
<argument>%kernel.bundles_metadata%</argument>
<argument>%twig.default_path%</argument>
<argument type="service" id="debug.file_link_formatter" on-invalid="null" />
<argument>%kernel.root_dir%</argument>
<argument>%kernel.project_dir%</argument>
<tag name="console.command" command="debug:twig" />
</service>

Expand Down
Expand Up @@ -264,7 +264,6 @@ private function createContainer(string $rootDir = __DIR__.'/Fixtures')
{
$container = new ContainerBuilder(new ParameterBag([
'kernel.cache_dir' => __DIR__,
'kernel.root_dir' => $rootDir,
'kernel.project_dir' => __DIR__,
'kernel.charset' => 'UTF-8',
'kernel.debug' => false,
Expand Down
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig\Environment;
Expand Down Expand Up @@ -60,7 +60,7 @@ public function isEnabled()
return self::DISABLED !== $this->mode;
}

public function onKernelResponse(FilterResponseEvent $event)
public function onKernelResponse(ResponseEvent $event)
{
$response = $event->getResponse();
$request = $event->getRequest();
Expand Down
15 changes: 15 additions & 0 deletions src/Symfony/Component/HttpKernel/CHANGELOG.md
Expand Up @@ -8,6 +8,21 @@ CHANGELOG
* removed `ConfigDataCollector::getApplicationName()`
* removed `ConfigDataCollector::getApplicationVersion()`
* removed support for `Symfony\Component\Templating\EngineInterface` in `HIncludeFragmentRenderer`, use a `Twig\Environment` only
* removed `Client`, use `HttpKernelBrowser` instead
* removed the `Kernel::getRootDir()` and the `kernel.root_dir` parameter
* removed the `KernelInterface::getName()` and the `kernel.name` parameter
* removed the first and second constructor argument of `ConfigDataCollector`
* removed `ConfigDataCollector::getApplicationName()`
* removed `ConfigDataCollector::getApplicationVersion()`
* removed `FilterControllerArgumentsEvent`, use `ControllerArgumentsEvent` instead
* removed `FilterControllerEvent`, use `ControllerEvent` instead
* removed `FilterResponseEvent`, use `ResponseEvent` instead
* removed `GetResponseEvent`, use `RequestEvent` instead
* removed `GetResponseForControllerResultEvent`, use `ViewEvent` instead
* removed `GetResponseForExceptionEvent`, use `ExceptionEvent` instead
* removed `PostResponseEvent`, use `TerminateEvent` instead
* removed `TranslatorListener` in favor of `LocaleAwareListener`
* removed `SaveSessionListener` in favor of `AbstractSessionListener`

4.3.0
-----
Expand Down
18 changes: 0 additions & 18 deletions src/Symfony/Component/HttpKernel/Client.php

This file was deleted.

Expand Up @@ -211,20 +211,6 @@ public function getPhpTimezone()
return $this->data['php_timezone'];
}

/**
* Gets the application name.
*
* @return string The application name
*
* @deprecated since Symfony 4.2
*/
public function getAppName()
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);

return 'n/a';
}

/**
* Gets the environment.
*
Expand Down
Expand Up @@ -16,8 +16,8 @@
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
Expand Down Expand Up @@ -353,15 +353,15 @@ public function getForwardToken()
/**
* @final since Symfony 4.3
*/
public function onKernelController(FilterControllerEvent $event)
public function onKernelController(ControllerEvent $event)
{
$this->controllers[$event->getRequest()] = $event->getController();
}

/**
* @final since Symfony 4.3
*/
public function onKernelResponse(FilterResponseEvent $event)
public function onKernelResponse(ResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
Expand Down
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\ControllerEvent;

/**
* @author Fabien Potencier <fabien@symfony.com>
Expand Down Expand Up @@ -69,7 +69,7 @@ protected function guessRoute(Request $request, $controller)
*
* @final since Symfony 4.3
*/
public function onKernelController(FilterControllerEvent $event)
public function onKernelController(ControllerEvent $event)
{
$this->controllers[$event->getRequest()] = $event->getController();
}
Expand Down

0 comments on commit be0f5ff

Please sign in to comment.