You are here

public static function HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes in Drupal 9

Same name and namespace in other branches
  1. 8 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

1 call to HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes()
HtmlResponseAttachmentsProcessor::processHtmlHeadLink in core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
Transform a html_head_link array into html_head and http_header arrays.

File

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

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) : '';
}