X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony%2Fhttp-kernel%2FEventListener%2FSurrogateListener.php;fp=vendor%2Fsymfony%2Fhttp-kernel%2FEventListener%2FSurrogateListener.php;h=37d1b9d04eaad56233528c35e5bd7a5e0bbb3843;hp=dc815a216f6c00cb920c2690d57982c76fb3930f;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/symfony/http-kernel/EventListener/SurrogateListener.php b/vendor/symfony/http-kernel/EventListener/SurrogateListener.php index dc815a216..37d1b9d04 100644 --- a/vendor/symfony/http-kernel/EventListener/SurrogateListener.php +++ b/vendor/symfony/http-kernel/EventListener/SurrogateListener.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\HttpCache\HttpCache; use Symfony\Component\HttpKernel\HttpCache\SurrogateInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -25,11 +26,6 @@ class SurrogateListener implements EventSubscriberInterface { private $surrogate; - /** - * Constructor. - * - * @param SurrogateInterface $surrogate An SurrogateInterface instance - */ public function __construct(SurrogateInterface $surrogate = null) { $this->surrogate = $surrogate; @@ -37,16 +33,27 @@ class SurrogateListener implements EventSubscriberInterface /** * Filters the Response. - * - * @param FilterResponseEvent $event A FilterResponseEvent instance */ public function onKernelResponse(FilterResponseEvent $event) { - if (!$event->isMasterRequest() || null === $this->surrogate) { + if (!$event->isMasterRequest()) { + return; + } + + $kernel = $event->getKernel(); + $surrogate = $this->surrogate; + if ($kernel instanceof HttpCache) { + $surrogate = $kernel->getSurrogate(); + if (null !== $this->surrogate && $this->surrogate->getName() !== $surrogate->getName()) { + $surrogate = $this->surrogate; + } + } + + if (null === $surrogate) { return; } - $this->surrogate->addSurrogateControl($event->getResponse()); + $surrogate->addSurrogateControl($event->getResponse()); } public static function getSubscribedEvents()