function HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes

Same name in other branches
  1. 9 core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes()
  2. 8.9.x core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes()
  3. 11.x 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 241

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.