You are here

public function HtmlResponsePlaceholderStrategySubscriber::onRespond in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/EventSubscriber/HtmlResponsePlaceholderStrategySubscriber.php \Drupal\Core\EventSubscriber\HtmlResponsePlaceholderStrategySubscriber::onRespond()

Processes placeholders for HTML responses.

Parameters

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

File

core/lib/Drupal/Core/EventSubscriber/HtmlResponsePlaceholderStrategySubscriber.php, line 50
Contains \Drupal\Core\EventSubscriber\HtmlResponsePlaceholderStrategySubscriber.

Class

HtmlResponsePlaceholderStrategySubscriber
HTML response subscriber to allow for different placeholder strategies.

Namespace

Drupal\Core\EventSubscriber

Code

public function onRespond(FilterResponseEvent $event) {
  $response = $event
    ->getResponse();
  if (!$response instanceof HtmlResponse) {
    return;
  }
  $attachments = $response
    ->getAttachments();
  if (empty($attachments['placeholders'])) {
    return;
  }
  $attachments['placeholders'] = $this->placeholderStrategy
    ->processPlaceholders($attachments['placeholders']);
  $response
    ->setAttachments($attachments);
}