You are here

class RequestCloseSubscriber in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php \Drupal\Core\EventSubscriber\RequestCloseSubscriber

Subscriber for all responses.

Hierarchy

Expanded class hierarchy of RequestCloseSubscriber

1 string reference to 'RequestCloseSubscriber'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses RequestCloseSubscriber
request_close_subscriber in core/core.services.yml
Drupal\Core\EventSubscriber\RequestCloseSubscriber

File

core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php, line 18
Contains \Drupal\Core\EventSubscriber\RequestCloseSubscriber.

Namespace

Drupal\Core\EventSubscriber
View source
class RequestCloseSubscriber implements EventSubscriberInterface {

  /**
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * Constructs a new RequestCloseSubscriber instance.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   */
  function __construct(ModuleHandlerInterface $module_handler) {
    $this->moduleHandler = $module_handler;
  }

  /**
   * Performs end of request tasks.
   *
   * @todo The body of this function has just been copied almost verbatim from
   *   drupal_page_footer(). There's probably a lot in here that needs to get
   *   removed/changed. Also, if possible, do more light-weight shutdowns on
   *   AJAX requests.
   *
   * @param Symfony\Component\HttpKernel\Event\PostResponseEvent $event
   *   The Event to process.
   */
  public function onTerminate(PostResponseEvent $event) {
    $this->moduleHandler
      ->writeCache();
  }

  /**
   * Registers the methods in this class that should be listeners.
   *
   * @return array
   *   An array of event listener definitions.
   */
  static function getSubscribedEvents() {
    $events[KernelEvents::TERMINATE][] = array(
      'onTerminate',
      100,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RequestCloseSubscriber::$moduleHandler protected property
RequestCloseSubscriber::getSubscribedEvents static function Registers the methods in this class that should be listeners. Overrides EventSubscriberInterface::getSubscribedEvents
RequestCloseSubscriber::onTerminate public function Performs end of request tasks.
RequestCloseSubscriber::__construct function Constructs a new RequestCloseSubscriber instance.