You are here

class ResponseListener in Zircon Profile 8

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

ResponseListener fixes the Response headers based on the Request.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

Expanded class hierarchy of ResponseListener

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

File

vendor/symfony/http-kernel/EventListener/ResponseListener.php, line 23

Namespace

Symfony\Component\HttpKernel\EventListener
View source
class ResponseListener implements EventSubscriberInterface {
  private $charset;
  public function __construct($charset) {
    $this->charset = $charset;
  }

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

}

Members

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