You are here

public static function HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes()
  2. 10 core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes()

Formats an attribute string for an HTTP header.

@internal

Parameters

array $attributes: An associative array of attributes such as 'rel'.

Return value

string A ; separated string ready for insertion in a HTTP header. No escaping is performed for HTML entities, so this string is not safe to be printed.

See also

https://www.drupal.org/node/3000051

3 calls to HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes()
drupal_http_header_attributes in core/includes/common.inc
Formats an attribute string for an HTTP header.
HtmlResponseAttachmentsProcessor::processHtmlHeadLink in core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
Transform a html_head_link array into html_head and http_header arrays.
RendererLegacyTest::testHeaderAttributes in core/tests/Drupal/KernelTests/Core/Render/RendererLegacyTest.php
Tests deprecation of the drupal_http_header_attributes() function.

File

core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php, line 235

Class

HtmlResponseAttachmentsProcessor
Processes attachments of HTML responses.

Namespace

Drupal\Core\Render

Code

public static function formatHttpHeaderAttributes(array $attributes = []) {
  foreach ($attributes as $attribute => &$data) {
    if (is_array($data)) {
      $data = implode(' ', $data);
    }
    $data = $attribute . '="' . $data . '"';
  }
  return $attributes ? ' ' . implode('; ', $attributes) : '';
}