You are here

public function BoostResponseSubscriber::onRespond in Boost 8

Processes HtmlResponse event.

@todo, split things off into the class.

Parameters

\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The event to process.

File

src/EventSubscriber/BoostResponseSubscriber.php, line 104
Contains Drupal\boost\EventSubscriber\BoostResponseSubscriber

Class

BoostResponseSubscriber
Class BoostResponseSubscriber.

Namespace

Drupal\boost\EventSubscriber

Code

public function onRespond(FilterResponseEvent $event) {
  if ($this->account
    ->isAuthenticated()) {
    return;
  }
  $response = $event
    ->getResponse();
  if (!$response instanceof HtmlResponse) {
    return;
  }
  if ($response
    ->isRedirect() || $response
    ->isForbidden() || $response
    ->isNotFound()) {
    return;
  }

  // Process response attachments.
  $this->htmlResponseAttachmentsProcessor
    ->processAttachments($response);
  $content = $response
    ->getContent();

  // Create a cached response on the local file system.
  $this->boostCache
    ->index($content);
}