class EsiListener

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

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

Expanded class hierarchy of EsiListener

1 file declares its use of EsiListener
EsiListenerTest.php in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/EsiListenerTest.php

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php, line 26

Namespace

Symfony\Component\HttpKernel\EventListener
View source
class EsiListener implements EventSubscriberInterface {
  private $esi;

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

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

}

Members

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