You are here

private function CdnWarmer::parseHeaders in Warmer 2.x

Same name and namespace in other branches
  1. 8 modules/warmer_cdn/src/Plugin/warmer/CdnWarmer.php \Drupal\warmer_cdn\Plugin\warmer\CdnWarmer::parseHeaders()

Parses the configuration to extract the headers to inject in every request.

Return value

array The array of headers as expected by Guzzle.

1 call to CdnWarmer::parseHeaders()
CdnWarmer::warmMultiple in modules/warmer_cdn/src/Plugin/warmer/CdnWarmer.php
Warms multiple items.

File

modules/warmer_cdn/src/Plugin/warmer/CdnWarmer.php, line 97

Class

CdnWarmer
The cache warmer for the built-in entity cache.

Namespace

Drupal\warmer_cdn\Plugin\warmer

Code

private function parseHeaders() {
  $configuration = $this
    ->getConfiguration();
  $header_lines = $configuration['headers'];

  // Parse headers.
  return array_reduce($header_lines, function ($carry, $header_line) {
    list($name, $value_line) = array_map('trim', explode(':', $header_line));
    $values = array_map('trim', explode(';', $value_line));
    $values = array_filter($values);
    $values = count($values) === 1 ? reset($values) : $values;
    $carry[$name] = $values;
    return $carry;
  }, []);
}