You are here

class SurrogateListener in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/EventListener/SurrogateListener.php \Symfony\Component\HttpKernel\EventListener\SurrogateListener

SurrogateListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for Surrogates.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

Expanded class hierarchy of SurrogateListener

1 file declares its use of SurrogateListener
SurrogateListenerTest.php in vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php

File

vendor/symfony/http-kernel/EventListener/SurrogateListener.php, line 24

Namespace

Symfony\Component\HttpKernel\EventListener
View source
class SurrogateListener implements EventSubscriberInterface {
  private $surrogate;

  /**
   * Constructor.
   *
   * @param SurrogateInterface $surrogate An SurrogateInterface instance
   */
  public function __construct(SurrogateInterface $surrogate = null) {
    $this->surrogate = $surrogate;
  }

  /**
   * Filters the Response.
   *
   * @param FilterResponseEvent $event A FilterResponseEvent instance
   */
  public function onKernelResponse(FilterResponseEvent $event) {
    if (!$event
      ->isMasterRequest() || null === $this->surrogate) {
      return;
    }
    $this->surrogate
      ->addSurrogateControl($event
      ->getResponse());
  }
  public static function getSubscribedEvents() {
    return array(
      KernelEvents::RESPONSE => 'onKernelResponse',
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SurrogateListener::$surrogate private property
SurrogateListener::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. Overrides EventSubscriberInterface::getSubscribedEvents
SurrogateListener::onKernelResponse public function Filters the Response.
SurrogateListener::__construct public function Constructor.