Commit d02fd0be authored by Fabien Potencier's avatar Fabien Potencier

changed before and after filters to only run for the master request (as it's...

changed before and after filters to only run for the master request (as it's mainly used for set up and tear down)
parent b5c10054
...@@ -354,6 +354,10 @@ through before and after filters. All you need to do is pass a closure:: ...@@ -354,6 +354,10 @@ through before and after filters. All you need to do is pass a closure::
// tear down // tear down
}); });
.. note::
The filters are only run for the "master" Request.
Error handlers Error handlers
-------------- --------------
......
...@@ -357,7 +357,9 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe ...@@ -357,7 +357,9 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
} catch (RoutingException $e) { } catch (RoutingException $e) {
// make sure onSilexBefore event is dispatched // make sure onSilexBefore event is dispatched
$this['dispatcher']->dispatch(SilexEvents::BEFORE); if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
$this['dispatcher']->dispatch(SilexEvents::BEFORE);
}
if ($e instanceof ResourceNotFoundException) { if ($e instanceof ResourceNotFoundException) {
$message = sprintf('No route found for "%s %s"', $this['request']->getMethod(), $this['request']->getPathInfo()); $message = sprintf('No route found for "%s %s"', $this['request']->getMethod(), $this['request']->getPathInfo());
...@@ -370,7 +372,9 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe ...@@ -370,7 +372,9 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
throw $e; throw $e;
} }
$this['dispatcher']->dispatch(SilexEvents::BEFORE); if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
$this['dispatcher']->dispatch(SilexEvents::BEFORE);
}
} }
/** /**
...@@ -408,7 +412,9 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe ...@@ -408,7 +412,9 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
*/ */
public function onKernelResponse(Event $event) public function onKernelResponse(Event $event)
{ {
$this['dispatcher']->dispatch(SilexEvents::AFTER); if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
$this['dispatcher']->dispatch(SilexEvents::AFTER);
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment