[HttpKernel] remove all deprecated event and replace their use
This commit is contained in:
parent
e33ee9d530
commit
48073ddcf9
@ -266,6 +266,7 @@ HttpKernel
|
|||||||
* Removed `PostResponseEvent`, use `TerminateEvent` instead
|
* Removed `PostResponseEvent`, use `TerminateEvent` instead
|
||||||
* Removed `TranslatorListener` in favor of `LocaleAwareListener`
|
* Removed `TranslatorListener` in favor of `LocaleAwareListener`
|
||||||
* The `DebugHandlersListener` class has been made `final`
|
* The `DebugHandlersListener` class has been made `final`
|
||||||
|
* Removed `SaveSessionListener` in favor of `AbstractSessionListener`
|
||||||
|
|
||||||
Intl
|
Intl
|
||||||
----
|
----
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Bridge\Monolog\Handler;
|
|||||||
|
|
||||||
use Monolog\Handler\ChromePHPHandler as BaseChromePhpHandler;
|
use Monolog\Handler\ChromePHPHandler as BaseChromePhpHandler;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ChromePhpHandler.
|
* ChromePhpHandler.
|
||||||
@ -34,7 +34,7 @@ class ChromePhpHandler extends BaseChromePhpHandler
|
|||||||
/**
|
/**
|
||||||
* Adds the headers to the response once it's created.
|
* Adds the headers to the response once it's created.
|
||||||
*/
|
*/
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Bridge\Monolog\Handler;
|
|||||||
|
|
||||||
use Monolog\Handler\FirePHPHandler as BaseFirePHPHandler;
|
use Monolog\Handler\FirePHPHandler as BaseFirePHPHandler;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FirePHPHandler.
|
* FirePHPHandler.
|
||||||
@ -34,7 +34,7 @@ class FirePHPHandler extends BaseFirePHPHandler
|
|||||||
/**
|
/**
|
||||||
* Adds the headers to the response once it's created.
|
* Adds the headers to the response once it's created.
|
||||||
*/
|
*/
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Bridge\Monolog\Handler;
|
|||||||
|
|
||||||
use Monolog\Handler\SwiftMailerHandler as BaseSwiftMailerHandler;
|
use Monolog\Handler\SwiftMailerHandler as BaseSwiftMailerHandler;
|
||||||
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
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.
|
* 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.
|
* After the kernel has been terminated we will always flush messages.
|
||||||
*/
|
*/
|
||||||
public function onKernelTerminate(PostResponseEvent $event)
|
public function onKernelTerminate(TerminateEvent $event)
|
||||||
{
|
{
|
||||||
$this->instantFlush = true;
|
$this->instantFlush = true;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Bridge\Monolog\Processor;
|
|||||||
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
|
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\HttpKernel\KernelEvents;
|
||||||
use Symfony\Contracts\Service\ResetInterface;
|
use Symfony\Contracts\Service\ResetInterface;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class RouteProcessor implements EventSubscriberInterface, ResetInterface
|
|||||||
$this->routeData = [];
|
$this->routeData = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRouteData(GetResponseEvent $event)
|
public function addRouteData(RequestEvent $event)
|
||||||
{
|
{
|
||||||
if ($event->isMasterRequest()) {
|
if ($event->isMasterRequest()) {
|
||||||
$this->reset();
|
$this->reset();
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Bridge\Monolog\Processor;
|
|||||||
|
|
||||||
use Monolog\Processor\WebProcessor as BaseWebProcessor;
|
use Monolog\Processor\WebProcessor as BaseWebProcessor;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +31,7 @@ class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface
|
|||||||
parent::__construct([], $extraFields);
|
parent::__construct([], $extraFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelRequest(GetResponseEvent $event)
|
public function onKernelRequest(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
if ($event->isMasterRequest()) {
|
if ($event->isMasterRequest()) {
|
||||||
$this->serverData = $event->getRequest()->server->all();
|
$this->serverData = $event->getRequest()->server->all();
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Bridge\Monolog\Processor\RouteProcessor;
|
|||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
|
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||||
|
|
||||||
class RouteProcessorTest extends TestCase
|
class RouteProcessorTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -122,9 +122,9 @@ class RouteProcessorTest extends TestCase
|
|||||||
$this->assertEquals(['extra' => []], $record);
|
$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);
|
$event->method('getRequest')->willReturn($request);
|
||||||
|
|
||||||
return $event;
|
return $event;
|
||||||
|
@ -15,7 +15,7 @@ use Monolog\Logger;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bridge\Monolog\Processor\WebProcessor;
|
use Symfony\Bridge\Monolog\Processor\WebProcessor;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
|
|
||||||
class WebProcessorTest extends TestCase
|
class WebProcessorTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -88,7 +88,7 @@ class WebProcessorTest extends TestCase
|
|||||||
$request->server->replace($server);
|
$request->server->replace($server);
|
||||||
$request->headers->replace($server);
|
$request->headers->replace($server);
|
||||||
|
|
||||||
$event = $this->getMockBuilder(RequestEvent::class)
|
$event = $this->getMockBuilder(ResponseEvent::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$event->expects($this->any())
|
$event->expects($this->any())
|
||||||
|
@ -19,7 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
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\Kernel;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
use Symfony\Component\Routing\RouteCollectionBuilder;
|
use Symfony\Component\Routing\RouteCollectionBuilder;
|
||||||
@ -30,7 +30,7 @@ class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface
|
|||||||
|
|
||||||
private $cacheDir;
|
private $cacheDir;
|
||||||
|
|
||||||
public function onKernelException(RequestEvent $event)
|
public function onKernelException(ExceptionEvent $event)
|
||||||
{
|
{
|
||||||
if ($event->getException() instanceof Danger) {
|
if ($event->getException() instanceof Danger) {
|
||||||
$event->setResponse(Response::create('It\'s dangerous to go alone. Take this ⚔'));
|
$event->setResponse(Response::create('It\'s dangerous to go alone. Take this ⚔'));
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Bundle\SecurityBundle\EventListener;
|
|||||||
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
|
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
|
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\HttpKernel\KernelEvents;
|
||||||
use Symfony\Component\Security\Http\Firewall;
|
use Symfony\Component\Security\Http\Firewall;
|
||||||
use Symfony\Component\Security\Http\FirewallMapInterface;
|
use Symfony\Component\Security\Http\FirewallMapInterface;
|
||||||
@ -41,7 +41,7 @@ class FirewallListener extends Firewall
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function configureLogoutUrlGenerator(GetResponseEvent $event)
|
public function configureLogoutUrlGenerator(RequestEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
|
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\HttpKernel\KernelEvents;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
@ -60,7 +60,7 @@ class WebDebugToolbarListener implements EventSubscriberInterface
|
|||||||
return self::DISABLED !== $this->mode;
|
return self::DISABLED !== $this->mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
$response = $event->getResponse();
|
$response = $event->getResponse();
|
||||||
$request = $event->getRequest();
|
$request = $event->getRequest();
|
||||||
|
@ -8,7 +8,15 @@ CHANGELOG
|
|||||||
* removed `ConfigDataCollector::getApplicationName()`
|
* removed `ConfigDataCollector::getApplicationName()`
|
||||||
* removed `ConfigDataCollector::getApplicationVersion()`
|
* removed `ConfigDataCollector::getApplicationVersion()`
|
||||||
* removed support for `Symfony\Component\Templating\EngineInterface` in `HIncludeFragmentRenderer`, use a `Twig\Environment` only
|
* 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
|
4.3.0
|
||||||
-----
|
-----
|
||||||
|
@ -16,8 +16,8 @@ use Symfony\Component\HttpFoundation\Cookie;
|
|||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
|
use Symfony\Component\HttpKernel\Event\ControllerEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -353,7 +353,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
|||||||
/**
|
/**
|
||||||
* @final since Symfony 4.3
|
* @final since Symfony 4.3
|
||||||
*/
|
*/
|
||||||
public function onKernelController(FilterControllerEvent $event)
|
public function onKernelController(ControllerEvent $event)
|
||||||
{
|
{
|
||||||
$this->controllers[$event->getRequest()] = $event->getController();
|
$this->controllers[$event->getRequest()] = $event->getController();
|
||||||
}
|
}
|
||||||
@ -361,7 +361,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
|||||||
/**
|
/**
|
||||||
* @final since Symfony 4.3
|
* @final since Symfony 4.3
|
||||||
*/
|
*/
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\DataCollector;
|
|||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
|
use Symfony\Component\HttpKernel\Event\ControllerEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
@ -69,7 +69,7 @@ class RouterDataCollector extends DataCollector
|
|||||||
*
|
*
|
||||||
* @final since Symfony 4.3
|
* @final since Symfony 4.3
|
||||||
*/
|
*/
|
||||||
public function onKernelController(FilterControllerEvent $event)
|
public function onKernelController(ControllerEvent $event)
|
||||||
{
|
{
|
||||||
$this->controllers[$event->getRequest()] = $event->getController();
|
$this->controllers[$event->getRequest()] = $event->getController();
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Event;
|
namespace Symfony\Component\HttpKernel\Event;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows filtering of controller arguments.
|
* Allows filtering of controller arguments.
|
||||||
*
|
*
|
||||||
@ -23,6 +26,27 @@ namespace Symfony\Component\HttpKernel\Event;
|
|||||||
*
|
*
|
||||||
* @author Christophe Coevoet <stof@notk.org>
|
* @author Christophe Coevoet <stof@notk.org>
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Event;
|
namespace Symfony\Component\HttpKernel\Event;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows filtering of a controller callable.
|
* Allows filtering of a controller callable.
|
||||||
*
|
*
|
||||||
@ -22,6 +25,29 @@ namespace Symfony\Component\HttpKernel\Event;
|
|||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Event;
|
namespace Symfony\Component\HttpKernel\Event;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows to create a response for a thrown exception.
|
* Allows to create a response for a thrown exception.
|
||||||
*
|
*
|
||||||
@ -24,6 +27,64 @@ namespace Symfony\Component\HttpKernel\Event;
|
|||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Event;
|
namespace Symfony\Component\HttpKernel\Event;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows to create a response for a request.
|
* Allows to create a response for a request.
|
||||||
*
|
*
|
||||||
@ -20,6 +22,37 @@ namespace Symfony\Component\HttpKernel\Event;
|
|||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Event;
|
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.
|
* Allows to filter a Response object.
|
||||||
*
|
*
|
||||||
@ -20,6 +24,29 @@ namespace Symfony\Component\HttpKernel\Event;
|
|||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Event;
|
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.
|
* Allows to execute logic after a response was sent.
|
||||||
*
|
*
|
||||||
@ -19,6 +23,24 @@ namespace Symfony\Component\HttpKernel\Event;
|
|||||||
*
|
*
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Event;
|
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.
|
* Allows to create a response for the return value of a controller.
|
||||||
*
|
*
|
||||||
@ -20,6 +23,39 @@ namespace Symfony\Component\HttpKernel\Event;
|
|||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ use Psr\Container\ContainerInterface;
|
|||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
|
||||||
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
|
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;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +47,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface
|
|||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelRequest(GetResponseEvent $event)
|
public function onKernelRequest(RequestEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
@ -67,7 +67,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface
|
|||||||
$this->sessionUsageStack[] = $session instanceof Session ? $session->getUsageIndex() : 0;
|
$this->sessionUsageStack[] = $session instanceof Session ? $session->getUsageIndex() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
@ -15,8 +15,8 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||||||
use Symfony\Component\HttpFoundation\Cookie;
|
use Symfony\Component\HttpFoundation\Cookie;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,7 +39,7 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface
|
|||||||
$this->sessionOptions = $sessionOptions;
|
$this->sessionOptions = $sessionOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelRequest(GetResponseEvent $event)
|
public function onKernelRequest(RequestEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
@ -63,7 +63,7 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface
|
|||||||
* Checks if session was initialized and saves if current request is master
|
* Checks if session was initialized and saves if current request is master
|
||||||
* Runs on 'kernel.response' in test environment.
|
* Runs on 'kernel.response' in test environment.
|
||||||
*/
|
*/
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\HttpKernel\EventListener;
|
namespace Symfony\Component\HttpKernel\EventListener;
|
||||||
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +34,7 @@ class AddRequestFormatsListener implements EventSubscriberInterface
|
|||||||
/**
|
/**
|
||||||
* Adds request formats.
|
* Adds request formats.
|
||||||
*/
|
*/
|
||||||
public function onKernelRequest(GetResponseEvent $event)
|
public function onKernelRequest(RequestEvent $event)
|
||||||
{
|
{
|
||||||
$request = $event->getRequest();
|
$request = $event->getRequest();
|
||||||
foreach ($this->formats as $format => $mimeTypes) {
|
foreach ($this->formats as $format => $mimeTypes) {
|
||||||
|
@ -21,7 +21,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
|
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\Event\KernelEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ class DebugHandlersListener implements EventSubscriberInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function onKernelException(GetResponseForExceptionEvent $event)
|
public function onKernelException(ExceptionEvent $event)
|
||||||
{
|
{
|
||||||
if (!$this->hasTerminatedWithException || !$event->isMasterRequest()) {
|
if (!$this->hasTerminatedWithException || !$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
@ -17,7 +17,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
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\Exception\HttpExceptionInterface;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
@ -41,7 +41,7 @@ class ExceptionListener implements EventSubscriberInterface
|
|||||||
$this->debug = $debug;
|
$this->debug = $debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logKernelException(GetResponseForExceptionEvent $event)
|
public function logKernelException(ExceptionEvent $event)
|
||||||
{
|
{
|
||||||
$e = FlattenException::create($event->getException());
|
$e = FlattenException::create($event->getException());
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class ExceptionListener implements EventSubscriberInterface
|
|||||||
* @param string $eventName
|
* @param string $eventName
|
||||||
* @param EventDispatcherInterface $eventDispatcher
|
* @param EventDispatcherInterface $eventDispatcher
|
||||||
*/
|
*/
|
||||||
public function onKernelException(GetResponseForExceptionEvent $event)
|
public function onKernelException(ExceptionEvent $event)
|
||||||
{
|
{
|
||||||
if (null === $this->controller) {
|
if (null === $this->controller) {
|
||||||
return;
|
return;
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Component\HttpKernel\EventListener;
|
|||||||
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
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\Exception\AccessDeniedHttpException;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
use Symfony\Component\HttpKernel\UriSigner;
|
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
|
* @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();
|
$request = $event->getRequest();
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
|
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\Event\KernelEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
use Symfony\Component\Routing\RequestContextAwareInterface;
|
use Symfony\Component\Routing\RequestContextAwareInterface;
|
||||||
@ -50,7 +50,7 @@ class LocaleListener implements EventSubscriberInterface
|
|||||||
$event->getRequest()->setDefaultLocale($this->defaultLocale);
|
$event->getRequest()->setDefaultLocale($this->defaultLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelRequest(GetResponseEvent $event)
|
public function onKernelRequest(RequestEvent $event)
|
||||||
{
|
{
|
||||||
$request = $event->getRequest();
|
$request = $event->getRequest();
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ namespace Symfony\Component\HttpKernel\EventListener;
|
|||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
|
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
|
use Symfony\Component\HttpKernel\Event\TerminateEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
use Symfony\Component\HttpKernel\Profiler\Profiler;
|
use Symfony\Component\HttpKernel\Profiler\Profiler;
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class ProfilerListener implements EventSubscriberInterface
|
|||||||
/**
|
/**
|
||||||
* Handles the onKernelException event.
|
* Handles the onKernelException event.
|
||||||
*/
|
*/
|
||||||
public function onKernelException(GetResponseForExceptionEvent $event)
|
public function onKernelException(ExceptionEvent $event)
|
||||||
{
|
{
|
||||||
if ($this->onlyMasterRequests && !$event->isMasterRequest()) {
|
if ($this->onlyMasterRequests && !$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
@ -71,7 +71,7 @@ class ProfilerListener implements EventSubscriberInterface
|
|||||||
/**
|
/**
|
||||||
* Handles the onKernelResponse event.
|
* Handles the onKernelResponse event.
|
||||||
*/
|
*/
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
$master = $event->isMasterRequest();
|
$master = $event->isMasterRequest();
|
||||||
if ($this->onlyMasterRequests && !$master) {
|
if ($this->onlyMasterRequests && !$master) {
|
||||||
@ -99,7 +99,7 @@ class ProfilerListener implements EventSubscriberInterface
|
|||||||
$this->parents[$request] = $this->requestStack->getParentRequest();
|
$this->parents[$request] = $this->requestStack->getParentRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelTerminate(PostResponseEvent $event)
|
public function onKernelTerminate(TerminateEvent $event)
|
||||||
{
|
{
|
||||||
// attach children to parents
|
// attach children to parents
|
||||||
foreach ($this->profiles as $request) {
|
foreach ($this->profiles as $request) {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\HttpKernel\EventListener;
|
namespace Symfony\Component\HttpKernel\EventListener;
|
||||||
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +34,7 @@ class ResponseListener implements EventSubscriberInterface
|
|||||||
/**
|
/**
|
||||||
* Filters the Response.
|
* Filters the Response.
|
||||||
*/
|
*/
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
@ -17,8 +17,8 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
|
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
@ -99,7 +99,7 @@ class RouterListener implements EventSubscriberInterface
|
|||||||
$this->setCurrentRequest($this->requestStack->getParentRequest());
|
$this->setCurrentRequest($this->requestStack->getParentRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelRequest(GetResponseEvent $event)
|
public function onKernelRequest(RequestEvent $event)
|
||||||
{
|
{
|
||||||
$request = $event->getRequest();
|
$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) {
|
if (!$this->debug || !($e = $event->getException()) instanceof NotFoundHttpException) {
|
||||||
return;
|
return;
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* 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 <http://tobion.de>
|
|
||||||
*
|
|
||||||
* @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]],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,7 +13,7 @@ namespace Symfony\Component\HttpKernel\EventListener;
|
|||||||
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +29,7 @@ class StreamedResponseListener implements EventSubscriberInterface
|
|||||||
/**
|
/**
|
||||||
* Filters the Response.
|
* Filters the Response.
|
||||||
*/
|
*/
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\HttpKernel\EventListener;
|
namespace Symfony\Component\HttpKernel\EventListener;
|
||||||
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
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\HttpCache;
|
||||||
use Symfony\Component\HttpKernel\HttpCache\SurrogateInterface;
|
use Symfony\Component\HttpKernel\HttpCache\SurrogateInterface;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
@ -36,7 +36,7 @@ class SurrogateListener implements EventSubscriberInterface
|
|||||||
/**
|
/**
|
||||||
* Filters the Response.
|
* Filters the Response.
|
||||||
*/
|
*/
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\HttpKernel\EventListener;
|
namespace Symfony\Component\HttpKernel\EventListener;
|
||||||
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +27,7 @@ class ValidateRequestListener implements EventSubscriberInterface
|
|||||||
/**
|
/**
|
||||||
* Performs the validation.
|
* Performs the validation.
|
||||||
*/
|
*/
|
||||||
public function onKernelRequest(GetResponseEvent $event)
|
public function onKernelRequest(RequestEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* 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));
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,8 +12,8 @@
|
|||||||
namespace Symfony\Component\Security\Http\Firewall;
|
namespace Symfony\Component\Security\Http\Firewall;
|
||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
|
||||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||||
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver;
|
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver;
|
||||||
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
|
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
|
||||||
@ -108,7 +108,7 @@ class ContextListener
|
|||||||
/**
|
/**
|
||||||
* Writes the security token into the session.
|
* Writes the security token into the session.
|
||||||
*/
|
*/
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
{
|
{
|
||||||
if (!$event->isMasterRequest()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user