Issue #2394883 by Gábor Hojtsy, plach, jhodgdon: Language setup for entity and field based rendering in views is independent, confusing UI, lacking test coverage

8.0.x
Alex Pott 2015-02-05 10:33:13 +00:00
parent c9cc83577d
commit f100d942e3
188 changed files with 470 additions and 858 deletions

View File

@ -153,8 +153,6 @@ display:
entity_type: node
entity_field: created
title: form
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
@ -162,8 +160,6 @@ display:
position: null
display_options:
path: test_bulk_form
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_2:
display_plugin: page
id: page_2
@ -184,5 +180,3 @@ display:
empty: true
content: 'This view is empty.'
plugin_id: text_custom
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -136,8 +136,6 @@ display:
empty: { }
relationships: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
feed_items:
display_plugin: feed
id: feed_items
@ -148,5 +146,3 @@ display:
display_description: ''
defaults:
arguments: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -141,16 +141,12 @@ display:
empty: { }
relationships: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
feed_1:
display_plugin: feed
id: feed_1
display_title: Feed
position: 2
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
style:
type: opml
options:
@ -389,8 +385,6 @@ display:
display_title: Page
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: aggregator/sources
menu:
type: normal

View File

@ -168,8 +168,6 @@ display:
entity_field: description
filters: { }
sorts: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
feed_1:
display_plugin: feed
id: feed_1
@ -181,5 +179,3 @@ display:
type: aggregator_rss
options:
view_mode: default
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -38,13 +38,8 @@ display:
table: views_test_data
field: name
title: test_view_block
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1:
display_plugin: block
id: block_1
display_title: Block
position: null
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -40,29 +40,18 @@ display:
table: views_test_data
field: name
title: test_view_block2
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1:
display_plugin: block
id: block_1
display_title: Block
position: null
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_2:
display_plugin: block
id: block_2
display_title: Block
position: null
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_3:
display_plugin: block
id: block_3
display_title: Block
position: null
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -52,8 +52,6 @@ display:
plugin_id: numeric
entity_type: block_content
entity_field: id
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -54,8 +54,6 @@ display:
plugin_id: block_content_id
entity_type: block_content
entity_field: id
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { }
display_plugin: default
display_title: Master

View File

@ -126,8 +126,6 @@ display:
footer: { }
empty: { }
relationships: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { }
arguments:
type:
@ -178,6 +176,4 @@ display:
position: null
display_options:
path: test-block_content-view
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { }

View File

@ -150,9 +150,7 @@ display:
empty: { }
relationships: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
rendering_language: translation_language_renderer
rendering_language: '***LANGUAGE_entity_translation***'
display_extenders: { }
page_bf:
display_plugin: page
@ -160,8 +158,6 @@ display:
display_title: 'Body filter page'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-filter
display_description: ''
title: 'Test body filters'
@ -219,8 +215,6 @@ display:
display_title: 'Body filter page Paris'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-paris
display_description: ''
title: 'Test body filters'
@ -278,8 +272,6 @@ display:
display_title: 'Info filter page'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-info-filter
display_description: ''
title: 'Test info filter'
@ -337,8 +329,6 @@ display:
display_title: 'Info filter page Paris'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-info-paris
display_description: ''
title: 'Test info filter'

View File

@ -22,8 +22,6 @@ display:
plugin_id: block_content_type
entity_type: block_content
entity_field: type
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -234,8 +234,6 @@ display:
content: 'No comments available.'
tokenize: false
plugin_id: text_custom
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1:
display_plugin: block
id: block_1
@ -244,7 +242,5 @@ display:
display_options:
block_description: 'Recent comments'
block_category: 'Lists (Views)'
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
allow:
items_per_page: true

View File

@ -352,8 +352,6 @@ display:
break_phrase: false
not: false
plugin_id: numeric
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { }
rest_export_1:
display_plugin: rest_export
@ -361,8 +359,6 @@ display:
display_title: 'REST export'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: node/%node/comments
pager:
type: some

View File

@ -147,8 +147,6 @@ display:
footer: { }
empty: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
@ -156,5 +154,3 @@ display:
position: 1
display_options:
path: test-comment-row
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -63,8 +63,6 @@ display:
entity_field: subject
filters: { }
sorts: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
feed_1:
display_plugin: feed
id: feed_1
@ -72,5 +70,3 @@ display:
position: null
display_options:
path: test-comment-rss
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -55,8 +55,6 @@ display:
type: default
row:
type: 'entity:node'
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -147,17 +147,13 @@ display:
footer: { }
empty: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
rendering_language: translation_language_renderer
rendering_language: '***LANGUAGE_entity_translation***'
page_bf:
display_plugin: page
id: page_bf
display_title: 'Body Comida'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-filter
display_description: ''
filters:
@ -214,8 +210,6 @@ display:
display_title: 'Body Paris'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-paris
display_description: ''
filters:
@ -272,8 +266,6 @@ display:
display_title: 'Title Comida'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-title-filter
display_description: ''
page_tp:
@ -282,8 +274,6 @@ display:
display_title: 'Title Paris'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-title-paris
display_description: ''
filters:

View File

@ -130,8 +130,6 @@ display:
empty: { }
relationships: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
@ -139,5 +137,3 @@ display:
position: 1
display_options:
path: test-contact-link
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -104,8 +104,6 @@ display:
value: 'No people available.'
format: plain_text
plugin_id: text
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
@ -113,5 +111,3 @@ display:
position: null
display_options:
path: test-entity-translations-link
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -56,8 +56,6 @@ display:
field: wid
order: ASC
plugin_id: standard
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
@ -65,5 +63,3 @@ display:
position: null
display_options:
path: test-dblog
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -109,8 +109,6 @@ display:
plugin_id: date
entity_type: node
entity_field: created
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
entity_reference_1:
display_plugin: entity_reference
id: entity_reference_1
@ -127,5 +125,3 @@ display:
type: none
options:
offset: 0
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -55,8 +55,6 @@ display:
field: field_test
relationship: none
plugin_id: standard
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default
@ -72,8 +70,6 @@ display:
field: reverse_field_test
relationship: none
plugin_id: standard
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed
display_title: Embed
id: embed_1

View File

@ -58,8 +58,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -680,8 +680,6 @@ display:
arguments: { }
group_by: true
show_admin_links: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
@ -709,8 +707,6 @@ display:
group_type: group
admin_label: 'File usage'
required: false
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_2:
display_plugin: page
id: page_2
@ -1060,5 +1056,3 @@ display:
group_type: group
admin_label: 'File usage'
required: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -47,8 +47,6 @@ display:
relationship: none
table: views_test_data
plugin_id: numeric
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -148,5 +148,3 @@ display:
plugin_id: numeric
filters: { }
sorts: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -165,8 +165,6 @@ display:
empty: { }
relationships: { }
fields: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1:
id: block_1
display_title: Block
@ -196,8 +194,6 @@ display:
specify_validation: true
plugin_id: date_year_month
entity_type: node
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
id: page_1
display_title: Page
@ -208,5 +204,3 @@ display:
type: views_query
options: { }
path: archive
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -501,8 +501,6 @@ display:
operator: AND
groups:
1: AND
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default
@ -523,8 +521,6 @@ display:
description: 'Find and manage content'
menu_name: admin
weight: -10
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page
display_title: Page
id: page_1

View File

@ -413,8 +413,6 @@ display:
plugin_id: standard
arguments: { }
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
use_more: true
use_more_always: true
use_more_text: More
@ -425,7 +423,3 @@ display:
id: block_1
display_title: Block
position: 1
display_options:
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -233,8 +233,6 @@ display:
relationships: { }
fields: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default
@ -266,13 +264,9 @@ display:
options:
relationship: none
view_mode: rss
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_options:
path: node
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page
display_title: Page
id: page_1

View File

@ -306,8 +306,6 @@ display:
footer: { }
empty: { }
sorts: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
filters:
langcode:
id: langcode
@ -406,8 +404,6 @@ display:
default: default
page_1: page_1
inherit_arguments: false
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
id: page_1
display_title: Page
@ -424,5 +420,3 @@ display:
weight: 0
menu_name: main
parent: ''
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -245,7 +245,7 @@ class NodeTranslationUITest extends ContentTranslationUITest {
// Enable the translation language renderer.
$view = \Drupal::entityManager()->getStorage('view')->load('frontpage');
$display = &$view->getDisplay('default');
$display['display_options']['rendering_language'] = 'translation_language_renderer';
$display['display_options']['rendering_language'] = '***LANGUAGE_entity_translation***';
$view->save();
// Need to check from the beginning, including the base_path, in the url

View File

@ -68,8 +68,6 @@ display:
relationships: { }
fields: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default
@ -95,8 +93,6 @@ display:
menu_name: tools
weight: 0
context: '1'
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page
display_title: Page
id: page_1

View File

@ -162,17 +162,13 @@ display:
empty: { }
relationships: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
rendering_language: translation_language_renderer
rendering_language: '***LANGUAGE_entity_translation***'
page_bf:
display_plugin: page
id: page_bf
display_title: 'Body filter page'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-filter
display_description: ''
title: 'Test body filters'
@ -240,8 +236,6 @@ display:
display_title: 'Body filter page Paris'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-paris
display_description: ''
title: 'Test body filters'
@ -309,8 +303,6 @@ display:
display_title: 'Title filter page'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-title-filter
display_description: ''
title: 'Test title filter'
@ -378,8 +370,6 @@ display:
display_title: 'Title filter page Paris'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-title-paris
display_description: ''
title: 'Test title filter'

View File

@ -22,8 +22,6 @@ display:
plugin_id: node_type
entity_type: node
entity_field: type
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -65,8 +65,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -282,14 +282,10 @@ display:
plugin_id: language
entity_type: node
entity_field: langcode
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-language

View File

@ -45,8 +45,6 @@ display:
plugin_id: standard
entity_type: node
entity_field: nid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
@ -54,5 +52,3 @@ display:
position: null
display_options:
path: test-node-bulk-form
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -52,8 +52,6 @@ display:
plugin_id: node_nid
entity_type: node
entity_field: nid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -52,8 +52,6 @@ display:
plugin_id: node_nid
entity_type: node
entity_field: nid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -47,8 +47,6 @@ display:
style:
type: default
title: test_node_row_plugin
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default
@ -56,8 +54,6 @@ display:
page_1:
display_options:
path: test-node-row-plugin
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page
display_title: Page
id: page_1

View File

@ -197,8 +197,6 @@ display:
plugin_id: node_type
entity_type: node
entity_field: type
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
@ -206,5 +204,3 @@ display:
position: null
display_options:
path: test-node-view
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -137,13 +137,9 @@ display:
operator: AND
groups:
1: AND
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_options:
path: test_status_extra
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page
display_title: Page
id: page_1

View File

@ -192,8 +192,6 @@ display:
not: false
plugin_id: number_list_field
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1:
display_plugin: block
id: block_1
@ -201,5 +199,3 @@ display:
position: 1
display_options:
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -191,8 +191,6 @@ display:
break_phrase: false
plugin_id: string_list_field
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1:
display_plugin: block
id: block_1
@ -200,5 +198,3 @@ display:
position: 1
display_options:
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -196,8 +196,6 @@ display:
relationships: { }
arguments: { }
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1:
display_plugin: block
id: block_1
@ -205,5 +203,3 @@ display:
position: 1
display_options:
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -44,8 +44,6 @@ display:
entity_field: id
title: 'Test serialize'
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
rest_export_1:
display_plugin: rest_export
id: rest_export_1
@ -55,5 +53,3 @@ display:
defaults:
access: false
path: test/serialize/entity
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -67,8 +67,6 @@ display:
plugin_id: date
title: 'Test serialize'
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
rest_export_1:
display_plugin: rest_export
id: rest_export_1
@ -86,8 +84,6 @@ display:
type: serializer
row:
type: data_field
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
rest_export_2:
display_plugin: rest_export
id: rest_export_2
@ -107,5 +103,3 @@ display:
type: serializer
row:
type: data_field
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -112,8 +112,6 @@ display:
entity_field: body
title: 'Test serialize'
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
rest_export_1:
display_plugin: rest_export
id: rest_export_1
@ -131,5 +129,3 @@ display:
type: serializer
row:
type: data_field
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -244,8 +244,6 @@ display:
order: DESC
entity_type: node
entity_field: created
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
@ -253,5 +251,3 @@ display:
position: null
display_options:
path: test_statistics_integration
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -235,8 +235,6 @@ display:
empty: { }
relationships: { }
fields: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
feed_1:
id: feed_1
display_title: Feed
@ -282,8 +280,6 @@ display:
options:
relationship: none
view_mode: default
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
id: page_1
display_title: Page
@ -294,5 +290,3 @@ display:
type: views_query
options: { }
path: taxonomy/term/%
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -161,6 +161,4 @@ display:
plugin_id: taxonomy
entity_type: taxonomy_term
entity_field: tid
field_langcode: '***LANGUAGE_site_default***'
field_langcode_add_to_query: null
rendering_language: translation_language_renderer
rendering_language: '***LANGUAGE_entity_translation***'

View File

@ -135,16 +135,12 @@ display:
empty: { }
relationships: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_dc:
display_plugin: page
id: page_dc
display_title: 'Description Comida'
position: 3
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_description: ''
path: test-desc-filter
filters:
@ -201,8 +197,6 @@ display:
display_title: 'Description Comida'
position: 3
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_description: ''
path: test-desc-paris
filters:
@ -259,8 +253,6 @@ display:
display_title: 'Field Comida'
position: 3
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_description: ''
path: test-field-filter
filters:
@ -317,8 +309,6 @@ display:
display_title: 'Field Paris'
position: 3
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_description: ''
path: test-field-paris
filters:
@ -375,8 +365,6 @@ display:
display_title: 'Name Comida'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-name-filter
display_description: ''
page_np:
@ -385,8 +373,6 @@ display:
display_title: 'Name Paris'
position: 1
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-name-paris
display_description: ''
filters:

View File

@ -177,5 +177,3 @@ display:
empty: { }
relationships: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -73,8 +73,6 @@ display:
style:
type: default
title: test_groupwise
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -83,8 +83,6 @@ display:
type: default
row:
type: 'entity:node'
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -131,5 +131,3 @@ display:
required: true
plugin_id: standard
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -154,5 +154,3 @@ display:
empty: { }
relationships: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -181,5 +181,3 @@ display:
validate_options: { }
plugin_id: tracker_user_uid
entity_type: node
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -815,8 +815,6 @@ display:
operator: AND
groups:
1: AND
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { }
page_1:
display_plugin: page
@ -841,6 +839,4 @@ display:
weight: 0
defaults:
show_admin_links: false
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { }

View File

@ -166,8 +166,6 @@ display:
empty: { }
relationships: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1:
display_plugin: block
id: block_1
@ -177,5 +175,3 @@ display:
display_description: 'A list of new users'
block_description: 'Who''s new'
block_category: User
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -196,8 +196,6 @@ display:
plugin_id: text_custom
relationships: { }
arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
who_s_online_block:
display_plugin: block
id: who_s_online_block
@ -206,5 +204,3 @@ display:
display_options:
block_description: 'Who''s online'
display_description: 'A list of users that are currently logged in.'
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -28,8 +28,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -32,8 +32,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default
@ -41,8 +39,6 @@ display:
page_1:
display_options:
path: test-role
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page
display_title: Page
id: page_1

View File

@ -138,5 +138,3 @@ display:
plugin_id: user_permissions
filters: { }
sorts: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -140,5 +140,3 @@ display:
plugin_id: standard
entity_type: user
entity_field: uid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -86,8 +86,6 @@ display:
style:
type: default
title: test_groupwise_user
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -58,8 +58,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -55,8 +55,6 @@ display:
plugin_id: boolean
entity_type: user
entity_field: status
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
@ -64,5 +62,3 @@ display:
position: null
display_options:
path: test-user-bulk-form
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -43,8 +43,6 @@ display:
entity_type: user
entity_field: changed
filters: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default
@ -52,8 +50,6 @@ display:
page_1:
display_options:
path: test_user_changed
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page
display_title: Page
id: page_1

View File

@ -130,5 +130,3 @@ display:
plugin_id: date
entity_type: user
entity_field: created
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -49,8 +49,6 @@ display:
anonymous: '0'
entity_type: user
entity_field: uid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default
@ -58,8 +56,6 @@ display:
page_1:
display_options:
path: test_user_name
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page
display_title: Page
id: page_1

View File

@ -111,8 +111,6 @@ display:
options:
default_field_elements: true
hide_empty: false
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -32,8 +32,6 @@ display:
plugin_id: user_uid
entity_type: user
entity_field: uid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -34,8 +34,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -34,8 +34,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -157,8 +157,6 @@ display:
entity_field: status
sorts: { }
title: test_user_role
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1:
display_plugin: page
id: page_1
@ -166,5 +164,3 @@ display:
position: null
display_options:
path: test-views-handler-field-role
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -53,8 +53,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -247,12 +247,6 @@ views_display:
hide_attachment_summary:
type: boolean
label: 'Hide attachments in summary'
field_langcode:
type: string
label: 'Field langcode'
field_langcode_add_to_query:
type: string
label: 'Add the field language to the query'
rendering_language:
type: string
label: 'Entity language'

View File

@ -0,0 +1,51 @@
<?php
/**
* @file
* Contains \Drupal\views\Entity\Render\ConfigurableLanguageRenderer.
*/
namespace Drupal\views\Entity\Render;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
/**
* Renders entities in a configured language.
*/
class ConfigurableLanguageRenderer extends RendererBase {
/**
* A specific language code for rendering if available.
*
* @var string|null
*/
protected $langcode;
/**
* Constructs a renderer object.
*
* @param \Drupal\views\ViewExecutable $view
* The entity row being rendered.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
* @param string|null $langcode
* A specific language code to set, if available.
*/
public function __construct(ViewExecutable $view, LanguageManagerInterface $language_manager, EntityTypeInterface $entity_type, $langcode) {
parent::__construct($view, $language_manager, $entity_type);
$this->langcode = $langcode;
}
/**
* {@inheritdoc}
*/
public function getLangcode(ResultRow $row) {
return $this->langcode;
}
}

View File

@ -1,26 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\views\Entity\Render\CurrentLanguageRenderer.
*/
namespace Drupal\views\Entity\Render;
use Drupal\views\ResultRow;
/**
* Renders entities in the current language.
*/
class CurrentLanguageRenderer extends RendererBase {
/**
* Returns NULL so that the current language is used.
*
* @param \Drupal\views\ResultRow $row
* The result row.
*/
protected function getLangcode(ResultRow $row) {
}
}

View File

@ -15,15 +15,9 @@ use Drupal\views\ResultRow;
class DefaultLanguageRenderer extends RendererBase {
/**
* Returns the language code associated to the given row.
*
* @param \Drupal\views\ResultRow $row
* The result row.
*
* @return string
* A language code.
* {@inheritdoc}
*/
protected function getLangcode(ResultRow $row) {
public function getLangcode(ResultRow $row) {
return $row->_entity->getUntranslated()->language()->getId();
}

View File

@ -0,0 +1,92 @@
<?php
/**
* @file
* Contains \Drupal\views\Entity\Render\EntityTranslationRenderTrait.
*/
namespace Drupal\views\Entity\Render;
use Drupal\views\Plugin\views\PluginBase;
/**
* Trait used to instantiate the view's entity language render.
*/
trait EntityTranslationRenderTrait {
/**
* The renderer to be used to render the entity row.
*
* @var \Drupal\views\Entity\Render\RendererBase
*/
protected $entityLanguageRenderer;
/**
* Returns the current renderer.
*
* @return \Drupal\views\Entity\Render\RendererBase
* The configured renderer.
*/
protected function getEntityTranslationRenderer() {
if (!isset($this->entityLanguageRenderer)) {
$view = $this->getView();
$rendering_language = $view->display_handler->getOption('rendering_language');
$langcode = NULL;
$dynamic_renderers = array(
'***LANGUAGE_entity_translation***' => 'TranslationLanguageRenderer',
'***LANGUAGE_entity_default***' => 'DefaultLanguageRenderer',
);
if (isset($dynamic_renderers[$rendering_language])) {
// Dynamic language set based on result rows or instance defaults.
$renderer = $dynamic_renderers[$rendering_language];
}
else {
if (strpos($rendering_language, '***LANGUAGE_') !== FALSE) {
$langcode = PluginBase::queryLanguageSubstitutions()[$rendering_language];
}
else {
// Specific langcode set.
$langcode = $rendering_language;
}
$renderer = 'ConfigurableLanguageRenderer';
}
$class = '\Drupal\views\Entity\Render\\' . $renderer;
$entity_type = $this->getEntityManager()->getDefinition($this->getEntityTypeId());
$this->entityLanguageRenderer = new $class($view, $this->getLanguageManager(), $entity_type, $langcode);
}
return $this->entityLanguageRenderer;
}
/**
* Returns the entity type identifier.
*
* @return string
* The entity type identifier.
*/
abstract public function getEntityTypeId();
/**
* Returns the entity manager.
*
* @return \Drupal\Core\Entity\EntityManagerInterface
* The entity manager.
*/
abstract protected function getEntityManager();
/**
* Returns the language manager.
*
* @return \Drupal\Core\Language\LanguageManagerInterface
* The language manager.
*/
abstract protected function getLanguageManager();
/**
* Returns the top object of a view.
*
* @return \Drupal\views\ViewExecutable
* The view object.
*/
abstract protected function getView();
}

View File

@ -23,7 +23,7 @@ abstract class RendererBase {
*
* @var \Drupal\views\ViewExecutable
*/
public $view = NULL;
public $view;
/**
* The language manager.
@ -62,6 +62,17 @@ abstract class RendererBase {
$this->entityType = $entity_type;
}
/**
* Returns the language code associated to the given row.
*
* @param \Drupal\views\ResultRow $row
* The result row.
*
* @return string
* A language code.
*/
abstract public function getLangcode(ResultRow $row);
/**
* Alters the query if needed.
*

View File

@ -13,7 +13,7 @@ use Drupal\views\ResultRow;
/**
* Renders entity translations in their active language.
*/
class TranslationLanguageRenderer extends DefaultLanguageRenderer {
class TranslationLanguageRenderer extends RendererBase {
/**
* Stores the field alias of the langcode column.
@ -71,7 +71,7 @@ class TranslationLanguageRenderer extends DefaultLanguageRenderer {
/**
* {@inheritdoc}
*/
protected function getLangcode(ResultRow $row) {
public function getLangcode(ResultRow $row) {
return isset($row->{$this->langcodeAlias}) ? $row->{$this->langcodeAlias} : $this->languageManager->getDefaultLanguage()->getId();
}

View File

@ -51,6 +51,13 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
*/
const INCLUDE_NEGOTIATED = 16;
/**
* Include entity row languages when listing languages.
*
* @see \Drupal\views\Plugin\views\PluginBase::listLanguages()
*/
const INCLUDE_ENTITY = 32;
/**
* Query string to indicate the site default language.
*
@ -490,16 +497,25 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
* note that this is not included in STATE_ALL.
* - \Drupal\views\Plugin\views\PluginBase::INCLUDE_NEGOTIATED: Add
* negotiated language types.
* - \Drupal\views\Plugin\views\PluginBase::INCLUDE_ENTITY: Add
* entity row language types. Note that these are only supported for
* display options, not substituted in queries.
*
* @return array
* An array of language names, keyed by the language code. Negotiated and
* special languages have special codes that are substituted in queries by
* static::queryLanguageSubstitutions().
* PluginBase::queryLanguageSubstitutions().
*/
protected function listLanguages($flags = LanguageInterface::STATE_ALL) {
$manager = \Drupal::languageManager();
$list = array();
// The entity languages should come first, if requested.
if ($flags & PluginBase::INCLUDE_ENTITY) {
$list['***LANGUAGE_entity_translation***'] = $this->t('Content language of view row');
$list['***LANGUAGE_entity_default***'] = $this->t('Original language of content in view row');
}
// The Language Manager class takes care of the STATE_SITE_DEFAULT case.
// It comes in with ID set to LanguageInterface::LANGCODE_SITE_DEFAULT.
// Since this is not a real language, surround it by '***LANGUAGE_...***',
@ -521,7 +537,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
// IDs by '***LANGUAGE_...***', to avoid query collisions.
if (isset($type['name'])) {
$id = '***LANGUAGE_' . $id . '***';
$list[$id] = $this->t('Language selected for !type', array('!type' => $type['name']));
$list[$id] = $this->t('!type language selected for page', array('!type' => $type['name']));
}
}
}
@ -533,7 +549,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
* Returns substitutions for Views queries for languages.
*
* This is needed so that the language options returned by
* $this->listLanguages() are able to be used in queries. It is called
* PluginBase::listLanguages() are able to be used in queries. It is called
* by the Views module implementation of hook_views_query_substitutions()
* to get the language-related substitutions.
*

View File

@ -195,15 +195,6 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$this->unpackOptions($this->options, $options);
}
// Convert the field_langcode and field_language_add_to_query settings.
$field_langcode = $this->getOption('field_langcode');
$field_language_add_to_query = $this->getOption('field_language_add_to_query');
if (isset($field_langcode)) {
$this->setOption('field_langcode', $field_langcode);
$this->setOption('field_langcode_add_to_query', $field_language_add_to_query);
$changed = TRUE;
}
// Mark the view as changed so the user has a chance to save it.
if ($changed) {
$this->view->changed = TRUE;
@ -539,14 +530,8 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
'group_by' => array(
'default' => FALSE,
),
'field_langcode' => array(
'default' => '***LANGUAGE_language_content***',
),
'field_langcode_add_to_query' => array(
'default' => TRUE,
),
'rendering_language' => array(
'default' => 'translation_language_renderer',
'default' => '***LANGUAGE_entity_translation***',
),
// These types are all plugins that can have individual settings
@ -1175,15 +1160,9 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$rendering_language_options = $this->buildRenderingLanguageOptions();
$options['rendering_language'] = array(
'category' => 'language',
'title' => $this->t('Entity Language'),
'title' => $this->t('Rendering Language'),
'value' => $rendering_language_options[$this->getOption('rendering_language')],
);
$language_options = $this->listLanguages(LanguageInterface::STATE_ALL | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED);
$options['field_langcode'] = array(
'category' => 'language',
'title' => $this->t('Field Language'),
'value' => $language_options[$this->getOption('field_langcode')],
'desc' => $this->t('All fields that support translations will be displayed in the selected language.'),
'desc' => $this->t('All content that supports translations will be displayed in the selected language.'),
);
}
@ -1533,36 +1512,15 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$this->view->query->buildOptionsForm($form['query']['options'], $form_state);
}
break;
case 'field_langcode':
$form['#title'] .= $this->t('Field Language');
if ($this->isBaseTableTranslatable()) {
$languages = $this->listLanguages(LanguageInterface::STATE_ALL | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED);
$form['field_langcode'] = array(
'#type' => 'select',
'#title' => $this->t('Field Language'),
'#description' => $this->t('All fields which support translations will be displayed in the selected language.'),
'#options' => $languages,
'#default_value' => $this->getOption('field_langcode'),
);
$form['field_langcode_add_to_query'] = array(
'#type' => 'checkbox',
'#title' => $this->t('When needed, add the field language condition to the query'),
'#default_value' => $this->getOption('field_langcode_add_to_query'),
);
}
else {
$form['field_language']['#markup'] = $this->t("You don't have translatable entity types.");
}
break;
case 'rendering_language':
$form['#title'] .= $this->t('Entity Language');
$form['#title'] .= $this->t('Rendering language');
if ($this->isBaseTableTranslatable()) {
$options = $this->buildRenderingLanguageOptions();
$form['rendering_language'] = array(
'#type' => 'select',
'#options' => $options,
'#title' => $this->t('Entity language'),
'#title' => $this->t('Rendering language'),
'#description' => $this->t('All content that supports translations will be displayed in the selected language.'),
'#default_value' => $this->getOption('rendering_language'),
);
}
@ -1882,10 +1840,6 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
case 'group_by':
$this->setOption($section, $form_state->getValue($section));
break;
case 'field_langcode':
$this->setOption('field_langcode', $form_state->getValue('field_langcode'));
$this->setOption('field_langcode_add_to_query', $form_state->getValue('field_langcode_add_to_query'));
break;
case 'rendering_language':
$this->setOption('rendering_language', $form_state->getValue('rendering_language'));
break;
@ -2515,11 +2469,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
*/
protected function buildRenderingLanguageOptions() {
// @todo Consider making these plugins. See https://drupal.org/node/2173811.
return array(
'current_language_renderer' => $this->t('Current language'),
'default_language_renderer' => $this->t('Default language'),
'translation_language_renderer' => $this->t('Translation language'),
);
return $this->listLanguages(LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED | PluginBase::INCLUDE_ENTITY);
}
/**

View File

@ -11,9 +11,6 @@ use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Xss as CoreXss;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldConfigInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\Field\FormatterPluginManager;
@ -24,15 +21,12 @@ use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\field\Views\FieldAPIHandlerTrait;
use Drupal\views\Entity\Render\EntityTranslationRenderTrait;
use Drupal\views\Plugin\CacheablePluginInterface;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\field\MultiItemsFieldHandlerInterface;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -45,6 +39,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* @ViewsField("field")
*/
class Field extends FieldPluginBase implements CacheablePluginInterface, MultiItemsFieldHandlerInterface {
use EntityTranslationRenderTrait;
use FieldAPIHandlerTrait;
@ -203,6 +198,33 @@ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiIt
}
}
/**
* {@inheritdoc}
*/
public function getEntityTypeId() {
return $this->getEntityType();
}
/**
* {@inheritdoc}
*/
protected function getEntityManager() {
return $this->entityManager;
}
/**
* {@inheritdoc}
*/
protected function getLanguageManager() {
return $this->languageManager;
}
/**
* {@inheritdoc}
*/
protected function getView() {
return $this->view;
}
/**
* {@inheritdoc}
*/
@ -247,24 +269,10 @@ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiIt
if ($this->add_field_table($use_groupby)) {
$this->ensureMyTable();
$this->addAdditionalFields($fields);
// If we are grouping by something on this field, we want to group by
// the displayed value, which is translated. So, we need to figure out
// which language should be used to translate the value. See also
// $this->field_langcode().
$field = $field_definition;
if ($field->isTranslatable() && !empty($this->view->display_handler->options['field_langcode_add_to_query'])) {
$column = $this->tableAlias . '.langcode';
$langcode = $this->view->display_handler->options['field_langcode'];
$substitutions = static::queryLanguageSubstitutions();
if (isset($substitutions[$langcode])) {
$langcode = $substitutions[$langcode];
}
$placeholder = $this->placeholder();
$langcode_fallback_candidates = $this->languageManager->getFallbackCandidates(array('langcode' => $langcode, 'operation' => 'views_query', 'data' => $this));
$this->query->addWhereExpression(0, "$column IN($placeholder) OR $column IS NULL", array($placeholder => $langcode_fallback_candidates));
}
}
// Let the configured entity translation renderer alter the query if needed.
$this->getEntityTranslationRenderer()->query($this->query);
}
/**
@ -758,7 +766,7 @@ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiIt
function process_entity(ResultRow $values, EntityInterface $entity) {
$processed_entity = clone $entity;
$langcode = $this->field_langcode($processed_entity);
$langcode = $this->getFieldLangcode($processed_entity, $values);
$processed_entity = $processed_entity->getTranslation($langcode);
// If we are grouping, copy our group fields into the cloned entity.
@ -886,16 +894,23 @@ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiIt
}
/**
* Return the language code of the language the field should be displayed in,
* according to the settings.
* Return the code of the language the field should be displayed in.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object the field value being processed is attached to.
* @param \Drupal\views\ResultRow $row
* The result row the field value being processed belongs to.
*
* @return string
* The field language code.
*/
function field_langcode(EntityInterface $entity) {
protected function getFieldLangcode(EntityInterface $entity, ResultRow $row) {
if ($this->getFieldDefinition()->isTranslatable()) {
$langcode = $this->view->display_handler->options['field_langcode'];
$substitutions = static::queryLanguageSubstitutions();
if (isset($substitutions[$langcode])) {
$langcode = $substitutions[$langcode];
}
// Even if the current field is not attached to the main entity, we use it
// to determine the field language, as we assume the same language should
// be used for all values belonging to a single row, when possible. Below
// we apply language fallback to ensure a valid value is always picked.
$langcode = $this->getEntityTranslationRenderer()->getLangcode($row);
// Give the Entity Field API a chance to fallback to a different language
// (or LanguageInterface::LANGCODE_NOT_SPECIFIED), in case the field has

View File

@ -8,10 +8,10 @@
namespace Drupal\views\Plugin\views\row;
use Drupal\Component\Utility\String;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\views\Entity\Render\EntityTranslationRenderTrait;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -25,6 +25,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* )
*/
class EntityRow extends RowPluginBase {
use EntityTranslationRenderTrait;
/**
* The table the entity is using for storage.
@ -54,13 +55,6 @@ class EntityRow extends RowPluginBase {
*/
protected $entityType;
/**
* The renderer to be used to render the entity row.
*
* @var \Drupal\views\Entity\Rendering\RendererBase
*/
protected $renderer;
/**
* The entity manager.
*
@ -109,6 +103,34 @@ class EntityRow extends RowPluginBase {
return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager'), $container->get('language_manager'));
}
/**
* {@inheritdoc}
*/
public function getEntityTypeId() {
return $this->entityType->id();
}
/**
* {@inheritdoc}
*/
protected function getEntityManager() {
return $this->entityManager;
}
/**
* {@inheritdoc}
*/
protected function getLanguageManager() {
return $this->languageManager;
}
/**
* {@inheritdoc}
*/
protected function getView() {
return $this->view;
}
/**
* Overrides Drupal\views\Plugin\views\row\RowPluginBase::defineOptions().
*/
@ -145,26 +167,12 @@ class EntityRow extends RowPluginBase {
}
}
/**
* Returns the current renderer.
*
* @return \Drupal\views\Entity\Render\RendererBase
* The configured renderer.
*/
protected function getRenderer() {
if (!isset($this->renderer)) {
$class = '\Drupal\views\Entity\Render\\' . Container::camelize($this->displayHandler->getOption('rendering_language'));
$this->renderer = new $class($this->view, $this->languageManager, $this->entityType);
}
return $this->renderer;
}
/**
* {@inheritdoc}
*/
public function query() {
parent::query();
$this->getRenderer()->query($this->view->getQuery());
$this->getEntityTranslationRenderer()->query($this->view->getQuery());
}
/**
@ -173,7 +181,7 @@ class EntityRow extends RowPluginBase {
public function preRender($result) {
parent::preRender($result);
if ($result) {
$this->getRenderer()->preRender($result);
$this->getEntityTranslationRenderer()->preRender($result);
}
}
@ -181,7 +189,7 @@ class EntityRow extends RowPluginBase {
* Overrides Drupal\views\Plugin\views\row\RowPluginBase::render().
*/
public function render($row) {
return $this->getRenderer()->render($row);
return $this->getEntityTranslationRenderer()->render($row);
}
/**

View File

@ -25,7 +25,7 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
*
* @var array
*/
public static $modules = array('field', 'filter', 'text', 'node', 'user', 'language', 'entity_reference');
public static $modules = array('field', 'filter', 'text', 'node', 'user', 'language', 'entity_reference', 'views_test_language');
/**
* Views used by this test.
@ -41,6 +41,13 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
*/
protected $langcodes;
/**
* An array of titles for each node per language.
*
* @var array
*/
protected $expected;
/**
* {@inheritdoc}
*/
@ -66,13 +73,8 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
$node_type = NodeType::create(array('type' => 'test'));
$node_type->setDisplaySubmitted(FALSE);
$node_type->save();
}
/**
* Tests the entity row renderers.
*/
public function testRenderers() {
$values = array();
$this->values = array();
$controller = \Drupal::entityManager()->getStorage('node');
$langcode_index = 0;
@ -85,19 +87,45 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
foreach ($langcodes as $langcode) {
// Ensure we have a predictable result order.
$values[$i][$langcode] = $i . '-' . $langcode . '-' . $this->randomMachineName();
$this->values[$i][$langcode] = $i . '-' . $langcode . '-' . $this->randomMachineName();
if ($langcode != $default_langcode) {
$node->addTranslation($langcode, array('title' => $values[$i][$langcode]));
$node->addTranslation($langcode, array('title' => $this->values[$i][$langcode]));
}
else {
$node->setTitle($values[$i][$langcode]);
$node->setTitle($this->values[$i][$langcode]);
}
$node->save();
}
}
}
/**
* Tests the entity row renderers.
*/
public function testEntityRenderers() {
$this->checkLanguageRenderers('page_1', $this->values);
}
/**
* Tests the field row renderers.
*/
public function testFieldRenderers() {
$this->checkLanguageRenderers('page_2', $this->values);
}
/**
* Checks that the language renderer configurations work as expected.
*
* @param string $display
* Name of display to test with.
* @param array $values
* An array of node information which are each an array of node titles
* associated with language keys appropriate for the translation of that
* node.
*/
protected function checkLanguageRenderers($display, $values) {
$expected = array(
$values[0]['en'],
$values[0]['en'],
@ -109,7 +137,7 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
$values[2]['en'],
$values[2]['en'],
);
$this->assertTranslations('current_language_renderer', $expected, 'The current language renderer behaves as expected.');
$this->assertTranslations($display, '***LANGUAGE_language_content***', $expected, 'The current language renderer behaves as expected.');
$expected = array(
$values[0]['en'],
@ -122,7 +150,7 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
$values[2]['l1'],
$values[2]['l1'],
);
$this->assertTranslations('default_language_renderer', $expected, 'The default language renderer behaves as expected.');
$this->assertTranslations($display, '***LANGUAGE_entity_default***', $expected, 'The default language renderer behaves as expected.');
$expected = array(
$values[0]['en'],
@ -135,12 +163,40 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
$values[2]['l0'],
$values[2]['l1'],
);
$this->assertTranslations('translation_language_renderer', $expected, 'The translation language renderer behaves as expected.');
$this->assertTranslations($display, '***LANGUAGE_entity_translation***', $expected, 'The translation language renderer behaves as expected.');
$expected = array(
$values[0][$this->langcodes[0]],
$values[0][$this->langcodes[0]],
$values[0][$this->langcodes[0]],
$values[1][$this->langcodes[0]],
$values[1][$this->langcodes[0]],
$values[1][$this->langcodes[0]],
$values[2][$this->langcodes[0]],
$values[2][$this->langcodes[0]],
$values[2][$this->langcodes[0]],
);
$this->assertTranslations($display, '***LANGUAGE_site_default***', $expected, 'The site default language renderer behaves as expected.');
$expected = array(
$values[0]['l0'],
$values[0]['l0'],
$values[0]['l0'],
$values[1]['l0'],
$values[1]['l0'],
$values[1]['l0'],
$values[2]['l0'],
$values[2]['l0'],
$values[2]['l0'],
);
$this->assertTranslations($display, 'l0', $expected, 'The language specific renderer behaves as expected.');
}
/**
* Checks that the view results match the expected values.
*
* @param string $display
* Name of display to test with.
* @param string $renderer_id
* The id of the renderer to be tested.
* @param array $expected
@ -153,17 +209,24 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
* @return bool
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertTranslations($renderer_id, array $expected, $message = '', $group = 'Other') {
protected function assertTranslations($display, $renderer_id, array $expected, $message = '', $group = 'Other') {
$view = Views::getView('test_entity_row_renderers');
$view->setDisplay($display);
$view->getDisplay()->setOption('rendering_language', $renderer_id);
$view->preview();
$result = TRUE;
foreach ($view->result as $index => $row) {
$build = $view->rowPlugin->render($row);
$output = drupal_render($build);
$result = strpos($output, $expected[$index]) !== FALSE;
if (!$result) {
$result = FALSE;
foreach ($expected as $index => $expected_output) {
if (!empty($view->result[$index])) {
$build = $view->rowPlugin->render($view->result[$index]);
$output = drupal_render($build);
$result = strpos($output, $expected_output) !== FALSE;
if (!$result) {
break;
}
}
else {
$result = FALSE;
break;
}
}

View File

@ -24,8 +24,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -59,8 +59,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -49,8 +49,6 @@ display:
table: views_test_data
plugin_id: numeric
use_ajax: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default
@ -58,8 +56,6 @@ display:
page_1:
display_options:
path: test_ajax_view
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page
display_title: Page
id: page_1

View File

@ -91,8 +91,6 @@ display:
type: views_query
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -42,8 +42,6 @@ display:
table: views
plugin_id: title
title: test_title_empty
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default
@ -60,8 +58,6 @@ display:
table: views
plugin_id: title
title: test_title_header
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page
display_title: 'Page 1'
id: page_1

View File

@ -43,8 +43,6 @@ display:
view_to_insert: 'test_simple_argument:default'
inherit_arguments: true
plugin_id: view
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -41,8 +41,6 @@ display:
relationship: none
table: views_test_data
plugin_id: numeric
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default
@ -57,8 +55,6 @@ display:
id: date_day
table: views_test_data
plugin_id: date_day
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed
id: embed_1
display_title: ''
@ -73,8 +69,6 @@ display:
id: date_month
table: views_test_data
plugin_id: date_month
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed
id: embed_2
display_title: ''
@ -89,8 +83,6 @@ display:
id: date_week
table: views_test_data
plugin_id: date_week
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed
id: embed_3
display_title: ''
@ -105,8 +97,6 @@ display:
id: date_year
table: views_test_data
plugin_id: date_year
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed
id: embed_4
display_title: ''
@ -121,8 +111,6 @@ display:
id: date_year_month
table: views_test_data
plugin_id: date_year_month
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed
id: embed_5
display_title: ''

View File

@ -58,8 +58,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -58,8 +58,6 @@ display:
type: default
row:
type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
display_title: Master
id: default

View File

@ -216,5 +216,3 @@ display:
entity_field: uid
plugin_id: numeric
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

Some files were not shown because too many files have changed in this diff Show More