diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index e7d5edd5e2..956b425da4 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -266,6 +266,7 @@ HttpKernel * Removed `PostResponseEvent`, use `TerminateEvent` instead * Removed `TranslatorListener` in favor of `LocaleAwareListener` * The `DebugHandlersListener` class has been made `final` + * Removed `SaveSessionListener` in favor of `AbstractSessionListener` Intl ---- diff --git a/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php b/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php index 4f98d58b1f..03321ba971 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php @@ -13,7 +13,7 @@ namespace Symfony\Bridge\Monolog\Handler; use Monolog\Handler\ChromePHPHandler as BaseChromePhpHandler; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; /** * ChromePhpHandler. @@ -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; diff --git a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php index b235fc101e..5171e30319 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php @@ -13,7 +13,7 @@ namespace Symfony\Bridge\Monolog\Handler; use Monolog\Handler\FirePHPHandler as BaseFirePHPHandler; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; /** * FirePHPHandler. @@ -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; diff --git a/src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php b/src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php index 93f2f72e64..1835192ac4 100644 --- a/src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php @@ -13,7 +13,7 @@ namespace Symfony\Bridge\Monolog\Handler; 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. @@ -36,7 +36,7 @@ class SwiftMailerHandler extends BaseSwiftMailerHandler /** * After the kernel has been terminated we will always flush messages. */ - public function onKernelTerminate(PostResponseEvent $event) + public function onKernelTerminate(TerminateEvent $event) { $this->instantFlush = true; } diff --git a/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php b/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php index 09507b55e7..141552525c 100644 --- a/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php @@ -13,7 +13,7 @@ namespace Symfony\Bridge\Monolog\Processor; 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; @@ -49,7 +49,7 @@ class RouteProcessor implements EventSubscriberInterface, ResetInterface $this->routeData = []; } - public function addRouteData(GetResponseEvent $event) + public function addRouteData(RequestEvent $event) { if ($event->isMasterRequest()) { $this->reset(); diff --git a/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php b/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php index 71bf71a816..6998584dec 100644 --- a/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php @@ -13,7 +13,7 @@ namespace Symfony\Bridge\Monolog\Processor; 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; /** @@ -31,7 +31,7 @@ class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface parent::__construct([], $extraFields); } - public function onKernelRequest(GetResponseEvent $event) + public function onKernelRequest(ResponseEvent $event) { if ($event->isMasterRequest()) { $this->serverData = $event->getRequest()->server->all(); diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/RouteProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/RouteProcessorTest.php index 5534240ba2..9487519e94 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/RouteProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/RouteProcessorTest.php @@ -16,7 +16,7 @@ use Symfony\Bridge\Monolog\Processor\RouteProcessor; 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 { @@ -122,9 +122,9 @@ class RouteProcessorTest extends TestCase $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; diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php index 54dbeee08f..992003bdbb 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php @@ -15,7 +15,7 @@ use Monolog\Logger; 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 { @@ -88,7 +88,7 @@ class WebProcessorTest extends TestCase $request->server->replace($server); $request->headers->replace($server); - $event = $this->getMockBuilder(RequestEvent::class) + $event = $this->getMockBuilder(ResponseEvent::class) ->disableOriginalConstructor() ->getMock(); $event->expects($this->any()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php index e765c6c23b..4338c9d428 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php @@ -19,7 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Routing\RouteCollectionBuilder; @@ -30,7 +30,7 @@ class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface private $cacheDir; - public function onKernelException(RequestEvent $event) + public function onKernelException(ExceptionEvent $event) { if ($event->getException() instanceof Danger) { $event->setResponse(Response::create('It\'s dangerous to go alone. Take this ⚔')); diff --git a/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php b/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php index 3dca451d9a..a90eabce99 100644 --- a/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php +++ b/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php @@ -14,7 +14,7 @@ namespace Symfony\Bundle\SecurityBundle\EventListener; 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; @@ -41,7 +41,7 @@ class FirewallListener extends Firewall /** * @internal */ - public function configureLogoutUrlGenerator(GetResponseEvent $event) + public function configureLogoutUrlGenerator(RequestEvent $event) { if (!$event->isMasterRequest()) { return; diff --git a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php index 1541c7113b..933f8d1032 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php @@ -16,7 +16,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; 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; @@ -60,7 +60,7 @@ class WebDebugToolbarListener implements EventSubscriberInterface return self::DISABLED !== $this->mode; } - public function onKernelResponse(FilterResponseEvent $event) + public function onKernelResponse(ResponseEvent $event) { $response = $event->getResponse(); $request = $event->getRequest(); diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index 9d29203ea5..adeda9908c 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -8,7 +8,15 @@ CHANGELOG * removed `ConfigDataCollector::getApplicationName()` * removed `ConfigDataCollector::getApplicationVersion()` * removed support for `Symfony\Component\Templating\EngineInterface` in `HIncludeFragmentRenderer`, use a `Twig\Environment` only - * removed `TranslatorListener` + * removed `TranslatorListener` in favor of `LocaleAwareListener` + * 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 `SaveSessionListener` in favor of `AbstractSessionListener` 4.3.0 ----- diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 32624c963f..b538a7f348 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -16,8 +16,8 @@ use Symfony\Component\HttpFoundation\Cookie; 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; /** @@ -353,7 +353,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter /** * @final since Symfony 4.3 */ - public function onKernelController(FilterControllerEvent $event) + public function onKernelController(ControllerEvent $event) { $this->controllers[$event->getRequest()] = $event->getController(); } @@ -361,7 +361,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter /** * @final since Symfony 4.3 */ - public function onKernelResponse(FilterResponseEvent $event) + public function onKernelResponse(ResponseEvent $event) { if (!$event->isMasterRequest()) { return; diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php index 65fc90dc19..3baff539a8 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php @@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\DataCollector; 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 @@ -69,7 +69,7 @@ class RouterDataCollector extends DataCollector * * @final since Symfony 4.3 */ - public function onKernelController(FilterControllerEvent $event) + public function onKernelController(ControllerEvent $event) { $this->controllers[$event->getRequest()] = $event->getController(); } diff --git a/src/Symfony/Component/HttpKernel/Event/ControllerArgumentsEvent.php b/src/Symfony/Component/HttpKernel/Event/ControllerArgumentsEvent.php index 3dc6ea50ed..a6265277bd 100644 --- a/src/Symfony/Component/HttpKernel/Event/ControllerArgumentsEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/ControllerArgumentsEvent.php @@ -11,6 +11,9 @@ namespace Symfony\Component\HttpKernel\Event; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\HttpKernelInterface; + /** * Allows filtering of controller arguments. * @@ -23,6 +26,27 @@ namespace Symfony\Component\HttpKernel\Event; * * @author Christophe Coevoet */ -class ControllerArgumentsEvent extends FilterControllerArgumentsEvent +class ControllerArgumentsEvent extends ControllerEvent { + private $arguments; + + public function __construct(HttpKernelInterface $kernel, callable $controller, array $arguments, Request $request, ?int $requestType) + { + parent::__construct($kernel, $controller, $request, $requestType); + + $this->arguments = $arguments; + } + + /** + * @return array + */ + public function getArguments() + { + return $this->arguments; + } + + public function setArguments(array $arguments) + { + $this->arguments = $arguments; + } } diff --git a/src/Symfony/Component/HttpKernel/Event/ControllerEvent.php b/src/Symfony/Component/HttpKernel/Event/ControllerEvent.php index 9afb818a1d..ddb0226774 100644 --- a/src/Symfony/Component/HttpKernel/Event/ControllerEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/ControllerEvent.php @@ -11,6 +11,9 @@ namespace Symfony\Component\HttpKernel\Event; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\HttpKernelInterface; + /** * Allows filtering of a controller callable. * @@ -22,6 +25,29 @@ namespace Symfony\Component\HttpKernel\Event; * * @author Bernhard Schussek */ -class ControllerEvent extends FilterControllerEvent +class ControllerEvent extends KernelEvent { + private $controller; + + public function __construct(HttpKernelInterface $kernel, callable $controller, Request $request, ?int $requestType) + { + parent::__construct($kernel, $request, $requestType); + + $this->setController($controller); + } + + /** + * Returns the current controller. + * + * @return callable + */ + public function getController() + { + return $this->controller; + } + + public function setController(callable $controller) + { + $this->controller = $controller; + } } diff --git a/src/Symfony/Component/HttpKernel/Event/ExceptionEvent.php b/src/Symfony/Component/HttpKernel/Event/ExceptionEvent.php index d3b2d8f606..ae3b4ef2b3 100644 --- a/src/Symfony/Component/HttpKernel/Event/ExceptionEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/ExceptionEvent.php @@ -11,6 +11,9 @@ namespace Symfony\Component\HttpKernel\Event; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\HttpKernelInterface; + /** * Allows to create a response for a thrown exception. * @@ -24,6 +27,64 @@ namespace Symfony\Component\HttpKernel\Event; * * @author Bernhard Schussek */ -class ExceptionEvent extends GetResponseForExceptionEvent +class ExceptionEvent extends RequestEvent { + /** + * The exception object. + * + * @var \Exception + */ + private $exception; + + /** + * @var bool + */ + private $allowCustomResponseCode = false; + + public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, \Exception $e) + { + parent::__construct($kernel, $request, $requestType); + + $this->setException($e); + } + + /** + * Returns the thrown exception. + * + * @return \Exception The thrown exception + */ + public function getException() + { + return $this->exception; + } + + /** + * Replaces the thrown exception. + * + * This exception will be thrown if no response is set in the event. + * + * @param \Exception $exception The thrown exception + */ + public function setException(\Exception $exception) + { + $this->exception = $exception; + } + + /** + * Mark the event as allowing a custom response code. + */ + public function allowCustomResponseCode() + { + $this->allowCustomResponseCode = true; + } + + /** + * Returns true if the event allows a custom response code. + * + * @return bool + */ + public function isAllowingCustomResponseCode() + { + return $this->allowCustomResponseCode; + } } diff --git a/src/Symfony/Component/HttpKernel/Event/FilterControllerArgumentsEvent.php b/src/Symfony/Component/HttpKernel/Event/FilterControllerArgumentsEvent.php deleted file mode 100644 index ac8e0263ca..0000000000 --- a/src/Symfony/Component/HttpKernel/Event/FilterControllerArgumentsEvent.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * @deprecated since Symfony 4.3, use ControllerArgumentsEvent instead - */ -class FilterControllerArgumentsEvent extends ControllerEvent -{ - private $arguments; - - public function __construct(HttpKernelInterface $kernel, callable $controller, array $arguments, Request $request, ?int $requestType) - { - parent::__construct($kernel, $controller, $request, $requestType); - - $this->arguments = $arguments; - } - - /** - * @return array - */ - public function getArguments() - { - return $this->arguments; - } - - public function setArguments(array $arguments) - { - $this->arguments = $arguments; - } -} diff --git a/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php b/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php deleted file mode 100644 index 74fa681f80..0000000000 --- a/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * @deprecated since Symfony 4.3, use ControllerEvent instead - */ -class FilterControllerEvent extends KernelEvent -{ - private $controller; - - public function __construct(HttpKernelInterface $kernel, callable $controller, Request $request, ?int $requestType) - { - parent::__construct($kernel, $request, $requestType); - - $this->setController($controller); - } - - /** - * Returns the current controller. - * - * @return callable - */ - public function getController() - { - return $this->controller; - } - - public function setController(callable $controller) - { - $this->controller = $controller; - } -} diff --git a/src/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php b/src/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php deleted file mode 100644 index eaa2e82565..0000000000 --- a/src/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * @deprecated since Symfony 4.3, use ResponseEvent instead - */ -class FilterResponseEvent extends KernelEvent -{ - private $response; - - public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, Response $response) - { - parent::__construct($kernel, $request, $requestType); - - $this->setResponse($response); - } - - /** - * Returns the current response object. - * - * @return Response - */ - public function getResponse() - { - return $this->response; - } - - /** - * Sets a new response object. - */ - public function setResponse(Response $response) - { - $this->response = $response; - } -} diff --git a/src/Symfony/Component/HttpKernel/Event/GetResponseEvent.php b/src/Symfony/Component/HttpKernel/Event/GetResponseEvent.php deleted file mode 100644 index fbed7beef5..0000000000 --- a/src/Symfony/Component/HttpKernel/Event/GetResponseEvent.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpFoundation\Response; - -/** - * @deprecated since Symfony 4.3, use RequestEvent instead - */ -class GetResponseEvent extends KernelEvent -{ - private $response; - - /** - * Returns the response object. - * - * @return Response|null - */ - public function getResponse() - { - return $this->response; - } - - /** - * Sets a response and stops event propagation. - */ - public function setResponse(Response $response) - { - $this->response = $response; - - $this->stopPropagation(); - } - - /** - * Returns whether a response was set. - * - * @return bool Whether a response was set - */ - public function hasResponse() - { - return null !== $this->response; - } -} diff --git a/src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php b/src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php deleted file mode 100644 index 4e70dbc63e..0000000000 --- a/src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * @deprecated since Symfony 4.3, use ViewEvent instead - */ -class GetResponseForControllerResultEvent extends RequestEvent -{ - /** - * The return value of the controller. - * - * @var mixed - */ - private $controllerResult; - - public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, $controllerResult) - { - parent::__construct($kernel, $request, $requestType); - - $this->controllerResult = $controllerResult; - } - - /** - * Returns the return value of the controller. - * - * @return mixed The controller return value - */ - public function getControllerResult() - { - return $this->controllerResult; - } - - /** - * Assigns the return value of the controller. - * - * @param mixed $controllerResult The controller return value - */ - public function setControllerResult($controllerResult) - { - $this->controllerResult = $controllerResult; - } -} diff --git a/src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php b/src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php deleted file mode 100644 index 3476c7e62a..0000000000 --- a/src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * @deprecated since Symfony 4.3, use ExceptionEvent instead - */ -class GetResponseForExceptionEvent extends RequestEvent -{ - /** - * The exception object. - * - * @var \Exception - */ - private $exception; - - /** - * @var bool - */ - private $allowCustomResponseCode = false; - - public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, \Exception $e) - { - parent::__construct($kernel, $request, $requestType); - - $this->setException($e); - } - - /** - * Returns the thrown exception. - * - * @return \Exception The thrown exception - */ - public function getException() - { - return $this->exception; - } - - /** - * Replaces the thrown exception. - * - * This exception will be thrown if no response is set in the event. - * - * @param \Exception $exception The thrown exception - */ - public function setException(\Exception $exception) - { - $this->exception = $exception; - } - - /** - * Mark the event as allowing a custom response code. - */ - public function allowCustomResponseCode() - { - $this->allowCustomResponseCode = true; - } - - /** - * Returns true if the event allows a custom response code. - * - * @return bool - */ - public function isAllowingCustomResponseCode() - { - return $this->allowCustomResponseCode; - } -} diff --git a/src/Symfony/Component/HttpKernel/Event/PostResponseEvent.php b/src/Symfony/Component/HttpKernel/Event/PostResponseEvent.php deleted file mode 100644 index b86bf07742..0000000000 --- a/src/Symfony/Component/HttpKernel/Event/PostResponseEvent.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * @deprecated since Symfony 4.3, use TerminateEvent instead - */ -class PostResponseEvent extends KernelEvent -{ - private $response; - - public function __construct(HttpKernelInterface $kernel, Request $request, Response $response) - { - parent::__construct($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - - $this->response = $response; - } - - /** - * Returns the response for which this event was thrown. - * - * @return Response - */ - public function getResponse() - { - return $this->response; - } -} diff --git a/src/Symfony/Component/HttpKernel/Event/RequestEvent.php b/src/Symfony/Component/HttpKernel/Event/RequestEvent.php index c1beb929f3..0b2b98eeba 100644 --- a/src/Symfony/Component/HttpKernel/Event/RequestEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/RequestEvent.php @@ -11,6 +11,8 @@ namespace Symfony\Component\HttpKernel\Event; +use Symfony\Component\HttpFoundation\Response; + /** * Allows to create a response for a request. * @@ -20,6 +22,37 @@ namespace Symfony\Component\HttpKernel\Event; * * @author Bernhard Schussek */ -class RequestEvent extends GetResponseEvent +class RequestEvent extends KernelEvent { + private $response; + + /** + * Returns the response object. + * + * @return Response|null + */ + public function getResponse() + { + return $this->response; + } + + /** + * Sets a response and stops event propagation. + */ + public function setResponse(Response $response) + { + $this->response = $response; + + $this->stopPropagation(); + } + + /** + * Returns whether a response was set. + * + * @return bool Whether a response was set + */ + public function hasResponse() + { + return null !== $this->response; + } } diff --git a/src/Symfony/Component/HttpKernel/Event/ResponseEvent.php b/src/Symfony/Component/HttpKernel/Event/ResponseEvent.php index 88c1996eaa..1b979378b3 100644 --- a/src/Symfony/Component/HttpKernel/Event/ResponseEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/ResponseEvent.php @@ -11,6 +11,10 @@ namespace Symfony\Component\HttpKernel\Event; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpKernelInterface; + /** * Allows to filter a Response object. * @@ -20,6 +24,29 @@ namespace Symfony\Component\HttpKernel\Event; * * @author Bernhard Schussek */ -class ResponseEvent extends FilterResponseEvent +class ResponseEvent extends KernelEvent { + private $response; + + public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, Response $response) + { + parent::__construct($kernel, $request, $requestType); + + $this->setResponse($response); + } + + /** + * Returns the current response object. + * + * @return Response + */ + public function getResponse() + { + return $this->response; + } + + public function setResponse(Response $response) + { + $this->response = $response; + } } diff --git a/src/Symfony/Component/HttpKernel/Event/TerminateEvent.php b/src/Symfony/Component/HttpKernel/Event/TerminateEvent.php index 6ce23e43f3..e445aa786d 100644 --- a/src/Symfony/Component/HttpKernel/Event/TerminateEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/TerminateEvent.php @@ -11,6 +11,10 @@ namespace Symfony\Component\HttpKernel\Event; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpKernelInterface; + /** * Allows to execute logic after a response was sent. * @@ -19,6 +23,24 @@ namespace Symfony\Component\HttpKernel\Event; * * @author Jordi Boggiano */ -class TerminateEvent extends PostResponseEvent +class TerminateEvent extends KernelEvent { + private $response; + + public function __construct(HttpKernelInterface $kernel, Request $request, Response $response) + { + parent::__construct($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + + $this->response = $response; + } + + /** + * Returns the response for which this event was thrown. + * + * @return Response + */ + public function getResponse() + { + return $this->response; + } } diff --git a/src/Symfony/Component/HttpKernel/Event/ViewEvent.php b/src/Symfony/Component/HttpKernel/Event/ViewEvent.php index 1cb7e23980..61f30f0827 100644 --- a/src/Symfony/Component/HttpKernel/Event/ViewEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/ViewEvent.php @@ -11,6 +11,9 @@ namespace Symfony\Component\HttpKernel\Event; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\HttpKernelInterface; + /** * Allows to create a response for the return value of a controller. * @@ -20,6 +23,39 @@ namespace Symfony\Component\HttpKernel\Event; * * @author Bernhard Schussek */ -class ViewEvent extends GetResponseForControllerResultEvent +class ViewEvent extends RequestEvent { + /** + * The return value of the controller. + * + * @var mixed + */ + private $controllerResult; + + public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, $controllerResult) + { + parent::__construct($kernel, $request, $requestType); + + $this->controllerResult = $controllerResult; + } + + /** + * Returns the return value of the controller. + * + * @return mixed The controller return value + */ + public function getControllerResult() + { + return $this->controllerResult; + } + + /** + * Assigns the return value of the controller. + * + * @param mixed $controllerResult The controller return value + */ + public function setControllerResult($controllerResult) + { + $this->controllerResult = $controllerResult; + } } diff --git a/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php index d89bc813f7..e0275d6c47 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php @@ -15,9 +15,9 @@ use Psr\Container\ContainerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -47,7 +47,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface $this->container = $container; } - public function onKernelRequest(GetResponseEvent $event) + public function onKernelRequest(RequestEvent $event) { if (!$event->isMasterRequest()) { return; @@ -67,7 +67,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface $this->sessionUsageStack[] = $session instanceof Session ? $session->getUsageIndex() : 0; } - public function onKernelResponse(FilterResponseEvent $event) + public function onKernelResponse(ResponseEvent $event) { if (!$event->isMasterRequest()) { return; diff --git a/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php index 054695e6f2..4c854c6ab3 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php @@ -15,8 +15,8 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -39,7 +39,7 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface $this->sessionOptions = $sessionOptions; } - public function onKernelRequest(GetResponseEvent $event) + public function onKernelRequest(RequestEvent $event) { if (!$event->isMasterRequest()) { return; @@ -63,7 +63,7 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface * Checks if session was initialized and saves if current request is master * Runs on 'kernel.response' in test environment. */ - public function onKernelResponse(FilterResponseEvent $event) + public function onKernelResponse(ResponseEvent $event) { if (!$event->isMasterRequest()) { return; diff --git a/src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php b/src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php index 47c7069c9e..10f7651cad 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php @@ -12,7 +12,7 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -34,7 +34,7 @@ class AddRequestFormatsListener implements EventSubscriberInterface /** * Adds request formats. */ - public function onKernelRequest(GetResponseEvent $event) + public function onKernelRequest(RequestEvent $event) { $request = $event->getRequest(); foreach ($this->formats as $format => $mimeTypes) { diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index 87bd55e484..65f5b23fb1 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -21,7 +21,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; +use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Symfony\Component\HttpKernel\Event\KernelEvent; use Symfony\Component\HttpKernel\KernelEvents; @@ -153,7 +153,7 @@ class DebugHandlersListener implements EventSubscriberInterface /** * @internal */ - public function onKernelException(GetResponseForExceptionEvent $event) + public function onKernelException(ExceptionEvent $event) { if (!$this->hasTerminatedWithException || !$event->isMasterRequest()) { return; diff --git a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php index f8044537a8..a7bba951df 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php @@ -17,7 +17,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; +use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; @@ -41,7 +41,7 @@ class ExceptionListener implements EventSubscriberInterface $this->debug = $debug; } - public function logKernelException(GetResponseForExceptionEvent $event) + public function logKernelException(ExceptionEvent $event) { $e = FlattenException::create($event->getException()); @@ -52,7 +52,7 @@ class ExceptionListener implements EventSubscriberInterface * @param string $eventName * @param EventDispatcherInterface $eventDispatcher */ - public function onKernelException(GetResponseForExceptionEvent $event) + public function onKernelException(ExceptionEvent $event) { if (null === $this->controller) { return; diff --git a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php index f7d3dc6956..ba23391202 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php @@ -13,7 +13,7 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\UriSigner; @@ -51,7 +51,7 @@ class FragmentListener implements EventSubscriberInterface * * @throws AccessDeniedHttpException if the request does not come from a trusted IP */ - public function onKernelRequest(GetResponseEvent $event) + public function onKernelRequest(RequestEvent $event) { $request = $event->getRequest(); diff --git a/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php b/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php index cb8a194d49..6871737232 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php @@ -15,7 +15,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\Event\KernelEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Routing\RequestContextAwareInterface; @@ -50,7 +50,7 @@ class LocaleListener implements EventSubscriberInterface $event->getRequest()->setDefaultLocale($this->defaultLocale); } - public function onKernelRequest(GetResponseEvent $event) + public function onKernelRequest(RequestEvent $event) { $request = $event->getRequest(); diff --git a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php b/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php index 85a0aacb61..f5b7959ba2 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php @@ -14,9 +14,9 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\RequestMatcherInterface; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; +use Symfony\Component\HttpKernel\Event\ExceptionEvent; +use Symfony\Component\HttpKernel\Event\TerminateEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Profiler\Profiler; @@ -59,7 +59,7 @@ class ProfilerListener implements EventSubscriberInterface /** * Handles the onKernelException event. */ - public function onKernelException(GetResponseForExceptionEvent $event) + public function onKernelException(ExceptionEvent $event) { if ($this->onlyMasterRequests && !$event->isMasterRequest()) { return; @@ -71,7 +71,7 @@ class ProfilerListener implements EventSubscriberInterface /** * Handles the onKernelResponse event. */ - public function onKernelResponse(FilterResponseEvent $event) + public function onKernelResponse(ResponseEvent $event) { $master = $event->isMasterRequest(); if ($this->onlyMasterRequests && !$master) { @@ -99,7 +99,7 @@ class ProfilerListener implements EventSubscriberInterface $this->parents[$request] = $this->requestStack->getParentRequest(); } - public function onKernelTerminate(PostResponseEvent $event) + public function onKernelTerminate(TerminateEvent $event) { // attach children to parents foreach ($this->profiles as $request) { diff --git a/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php b/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php index 01973e222a..40933edd88 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php @@ -12,7 +12,7 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -34,7 +34,7 @@ class ResponseListener implements EventSubscriberInterface /** * Filters the Response. */ - public function onKernelResponse(FilterResponseEvent $event) + public function onKernelResponse(ResponseEvent $event) { if (!$event->isMasterRequest()) { return; diff --git a/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php b/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php index 01a95ebffb..c833aab0ab 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php @@ -17,8 +17,8 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; +use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -99,7 +99,7 @@ class RouterListener implements EventSubscriberInterface $this->setCurrentRequest($this->requestStack->getParentRequest()); } - public function onKernelRequest(GetResponseEvent $event) + public function onKernelRequest(RequestEvent $event) { $request = $event->getRequest(); @@ -146,7 +146,7 @@ class RouterListener implements EventSubscriberInterface } } - public function onKernelException(GetResponseForExceptionEvent $event) + public function onKernelException(ExceptionEvent $event) { if (!$this->debug || !($e = $event->getException()) instanceof NotFoundHttpException) { return; diff --git a/src/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php deleted file mode 100644 index b14153ad3c..0000000000 --- a/src/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.1, use AbstractSessionListener instead.', SaveSessionListener::class), E_USER_DEPRECATED); - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * @author Tobias Schultze - * - * @deprecated since Symfony 4.1, use AbstractSessionListener instead - */ -class SaveSessionListener implements EventSubscriberInterface -{ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $session = $event->getRequest()->getSession(); - if ($session && $session->isStarted()) { - $session->save(); - } - } - - public static function getSubscribedEvents() - { - return [ - // low priority but higher than StreamedResponseListener - KernelEvents::RESPONSE => [['onKernelResponse', -1000]], - ]; - } -} diff --git a/src/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php b/src/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php index f28f5d868a..3b75763b69 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php @@ -13,7 +13,7 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -29,7 +29,7 @@ class StreamedResponseListener implements EventSubscriberInterface /** * Filters the Response. */ - public function onKernelResponse(FilterResponseEvent $event) + public function onKernelResponse(ResponseEvent $event) { if (!$event->isMasterRequest()) { return; diff --git a/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php b/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php index 9c3e960b00..d1ef1da66e 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php @@ -12,7 +12,7 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\HttpCache\HttpCache; use Symfony\Component\HttpKernel\HttpCache\SurrogateInterface; use Symfony\Component\HttpKernel\KernelEvents; @@ -36,7 +36,7 @@ class SurrogateListener implements EventSubscriberInterface /** * Filters the Response. */ - public function onKernelResponse(FilterResponseEvent $event) + public function onKernelResponse(ResponseEvent $event) { if (!$event->isMasterRequest()) { return; diff --git a/src/Symfony/Component/HttpKernel/EventListener/ValidateRequestListener.php b/src/Symfony/Component/HttpKernel/EventListener/ValidateRequestListener.php index 69c86b4095..d33fd2e1ed 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ValidateRequestListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ValidateRequestListener.php @@ -12,7 +12,7 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -27,7 +27,7 @@ class ValidateRequestListener implements EventSubscriberInterface /** * Performs the validation. */ - public function onKernelRequest(GetResponseEvent $event) + public function onKernelRequest(RequestEvent $event) { if (!$event->isMasterRequest()) { return; diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/SaveSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/SaveSessionListenerTest.php deleted file mode 100644 index 6cdd7476c9..0000000000 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/SaveSessionListenerTest.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpKernel\Event\ResponseEvent; -use Symfony\Component\HttpKernel\EventListener\SaveSessionListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * @group legacy - */ -class SaveSessionListenerTest extends TestCase -{ - public function testOnlyTriggeredOnMasterRequest() - { - $listener = new SaveSessionListener(); - $event = $this->getMockBuilder(ResponseEvent::class)->disableOriginalConstructor()->getMock(); - $event->expects($this->once())->method('isMasterRequest')->willReturn(false); - $event->expects($this->never())->method('getRequest'); - - // sub request - $listener->onKernelResponse($event); - } - - public function testSessionSaved() - { - $listener = new SaveSessionListener(); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); - - $session = $this->getMockBuilder(SessionInterface::class)->disableOriginalConstructor()->getMock(); - $session->expects($this->once())->method('isStarted')->willReturn(true); - $session->expects($this->once())->method('save'); - - $request = new Request(); - $request->setSession($session); - $response = new Response(); - $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response)); - } -} diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 0aa5399c0c..8d626a1aed 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -12,8 +12,8 @@ namespace Symfony\Component\Security\Http\Firewall; use Psr\Log\LoggerInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver; use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface; @@ -108,7 +108,7 @@ class ContextListener /** * Writes the security token into the session. */ - public function onKernelResponse(FilterResponseEvent $event) + public function onKernelResponse(ResponseEvent $event) { if (!$event->isMasterRequest()) { return;