function HtmlResponseAttachmentsProcessor::processFeed

Same name in other branches
  1. 9 core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::processFeed()
  2. 8.9.x core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::processFeed()
  3. 11.x core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::processFeed()

Transform a 'feed' attachment into an 'html_head_link' attachment.

The RSS feed is a special case of 'html_head_link', so we just turn it into one.

Parameters

array $attached_feed: The ['#attached']['feed'] portion of a render array.

Return value

array An ['#attached']['html_head_link'] array, suitable for merging with another 'html_head_link' array.

1 call to HtmlResponseAttachmentsProcessor::processFeed()
HtmlResponseAttachmentsProcessor::processAttachments in core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
Processes the attachments of a response that has attachments.

File

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

Class

HtmlResponseAttachmentsProcessor
Processes attachments of HTML responses.

Namespace

Drupal\Core\Render

Code

protected function processFeed($attached_feed) {
    $html_head_link = [];
    foreach ($attached_feed as $item) {
        $feed_link = [
            'href' => $item[0],
            'rel' => 'alternate',
            'title' => empty($item[1]) ? '' : $item[1],
            'type' => 'application/rss+xml',
        ];
        $html_head_link[] = [
            $feed_link,
            FALSE,
        ];
    }
    return [
        'html_head_link' => $html_head_link,
    ];
}

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