Issue #3070978 by idebr: Remove early rendering of RSS channel elements in template_preprocess_views_view_rss()

merge-requests/55/head
Lee Rowlands 2019-08-13 06:52:54 +10:00
parent 530230fea3
commit 593813261d
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
4 changed files with 26 additions and 2 deletions

View File

@ -0,0 +1,6 @@
name: 'Views Test RSS'
type: module
description: 'Provides hooks to alter RSS output for testing purposes.'
package: Testing
version: VERSION
core: 8.x

View File

@ -0,0 +1,17 @@
<?php
/**
* @file
* Hook implementations for this module.
*/
/**
* Implements hook_preprocess_HOOK().
*/
function views_test_rss_preprocess_views_view_rss(&$variables) {
$variables['channel_elements'][] = [
'#type' => 'html_tag',
'#tag' => 'copyright',
'#value' => t('Copyright 2019 Dries Buytaert'),
];
}

View File

@ -26,7 +26,7 @@ class DisplayFeedTest extends ViewTestBase {
*
* @var array
*/
public static $modules = ['block', 'node', 'views'];
public static $modules = ['block', 'node', 'views', 'views_test_rss'];
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
@ -63,6 +63,7 @@ class DisplayFeedTest extends ViewTestBase {
$this->drupalGet('test-feed-display.xml');
$this->assertEquals($site_name, $this->getSession()->getDriver()->getText('//title'));
$this->assertEquals($frontpage_url, $this->getSession()->getDriver()->getText('//link'));
$this->assertEquals('Copyright 2019 Dries Buytaert', $this->getSession()->getDriver()->getText('//channel/copyright'));
$this->assertEquals($node_title, $this->getSession()->getDriver()->getText('//item/title'));
// Verify HTML is properly escaped in the description field.
$this->assertRaw('&lt;p&gt;A paragraph&lt;/p&gt;');

View File

@ -870,7 +870,7 @@ function template_preprocess_views_view_rss(&$variables) {
$variables['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId();
$variables['namespaces'] = new Attribute($style->namespaces);
$variables['items'] = $items;
$variables['channel_elements'] = \Drupal::service('renderer')->render($style->channel_elements);
$variables['channel_elements'] = $style->channel_elements;
// During live preview we don't want to output the header since the contents
// of the feed are being displayed inside a normal HTML page.