protected HtmlResponseAttachmentsProcessor::processHtmlHeadLink(array $html_head_link)
Transform a html_head_link array into html_head and http_header arrays.
html_head_link is a special case of html_head which can be present as a link item in the HTML head section, and also as a Link: HTTP header, depending on options in the render array. Processing it can add to both the html_head and http_header sections.
array $html_head_link: The 'html_head_link' value of a render array. Each head link is specified by a two-element array:
array An ['#attached'] section of a render array. This allows us to easily merge the results with other render arrays. The array could contain the following keys:
protected function processHtmlHeadLink(array $html_head_link) { $attached = []; foreach ($html_head_link as $item) { $attributes = $item[0]; $should_add_header = isset($item[1]) ? $item[1] : FALSE; $element = array( '#tag' => 'link', '#attributes' => $attributes, ); $href = $attributes['href']; $attached['html_head'][] = [$element, 'html_head_link:' . $attributes['rel'] . ':' . $href]; if ($should_add_header) { // Also add a HTTP header "Link:". $href = '<' . Html::escape($attributes['href'] . '>'); unset($attributes['href']); $attached['http_header'][] = ['Link', $href . drupal_http_header_attributes($attributes), TRUE]; } } return $attached; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!HtmlResponseAttachmentsProcessor.php/function/HtmlResponseAttachmentsProcessor::processHtmlHeadLink/8.1.x