Skip to content
Snippets Groups Projects
Commit e1ba9e5d authored by Sascha Grossenbacher's avatar Sascha Grossenbacher
Browse files

Revert "Issue #3458099 by scott_euser, catch, oily, smustgrave, nicxvan: Views...

Revert "Issue #3458099 by scott_euser, catch, oily, smustgrave, nicxvan: Views handler loading should respect configuration"

This reverts commit b9a10a16.
parent 38dd1c40
No related branches found
No related tags found
1 merge request!11360Revert "Issue #3458099 by scott_euser, catch, oily, smustgrave, nicxvan: Views...
Showing
with 210 additions and 471 deletions
<?php
/**
* @file
* Install function for the Rest Test Views module.
*/
declare(strict_types=1);
use Drupal\views\Tests\ViewTestData;
/**
* Implements hook_install().
*/
function rest_test_views_install(): void {
// Install the state and schema by for views test data.
\Drupal::state()->set('views_test_data_schema', ViewTestData::schemaDefinition());
\Drupal::state()->set('views_test_data_views_data', ViewTestData::viewsData());
drupal_flush_all_caches();
}
...@@ -2,9 +2,7 @@ langcode: en ...@@ -2,9 +2,7 @@ langcode: en
status: true status: true
dependencies: dependencies:
module: module:
- entity_test
- rest - rest
- serialization
- user - user
id: test_serializer_display_entity id: test_serializer_display_entity
label: 'Test serialize display entity rows' label: 'Test serialize display entity rows'
...@@ -15,60 +13,42 @@ base_table: entity_test ...@@ -15,60 +13,42 @@ base_table: entity_test
base_field: id base_field: id
display: display:
default: default:
display_plugin: default
id: default id: default
display_title: Default display_title: Default
display_plugin: default
position: null position: null
display_options: display_options:
title: 'Test serialize'
exposed_form:
type: basic
access: access:
type: perm type: perm
options: options:
perm: 'access content' perm: 'access content'
cache: cache:
type: tag type: tag
query:
type: views_query
exposed_form:
type: basic
style:
type: serializer
row:
type: data_entity
sorts: sorts:
id: id:
id: standard id: standard
table: entity_test table: entity_test
field: id field: id
order: DESC
plugin_id: date
entity_type: entity_test entity_type: entity_test
entity_field: id entity_field: id
plugin_id: date title: 'Test serialize'
order: DESC
arguments: { } arguments: { }
style:
type: serializer
row:
type: data_entity
query:
type: views_query
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- entity_test_view_grants
- 'languages:language_interface'
- request_format
- url.query_args
- user.permissions
tags: { }
rest_export_1: rest_export_1:
display_plugin: rest_export
id: rest_export_1 id: rest_export_1
display_title: serializer display_title: serializer
display_plugin: rest_export
position: null position: null
display_options: display_options:
defaults: defaults:
access: false access: false
display_extenders: { }
path: test/serialize/entity path: test/serialize/entity
cache_metadata:
max-age: -1
contexts:
- entity_test_view_grants
- 'languages:language_interface'
- request_format
tags: { }
...@@ -3,9 +3,7 @@ status: true ...@@ -3,9 +3,7 @@ status: true
dependencies: dependencies:
module: module:
- rest - rest
- serialization
- user - user
- views_test_data
id: test_serializer_display_field id: test_serializer_display_field
label: 'Test serializer display field rows' label: 'Test serializer display field rows'
module: rest module: rest
...@@ -15,19 +13,32 @@ base_table: views_test_data ...@@ -15,19 +13,32 @@ base_table: views_test_data
base_field: id base_field: id
display: display:
default: default:
display_plugin: default
id: default id: default
display_title: Default display_title: Default
display_plugin: default
position: null position: null
display_options: display_options:
title: 'Test serialize' access:
type: perm
options:
perm: 'access content'
cache:
type: tag
query:
type: views_query
exposed_form:
type: basic
style:
type: serializer
row:
type: data_field
fields: fields:
name: name:
id: name id: name
table: views_test_data table: views_test_data
field: name field: name
plugin_id: string
label: '' label: ''
plugin_id: string
nothing: nothing:
id: nothing id: nothing
table: views table: views
...@@ -45,71 +56,49 @@ display: ...@@ -45,71 +56,49 @@ display:
id: created id: created
table: views_test_data table: views_test_data
field: created field: created
plugin_id: date type: timestamp
date_format: timestamp settings:
custom_date_format: '' date_format: medium
timezone: '' custom_date_format: ''
exposed_form: timezone: ''
type: basic plugin_id: field
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
sorts: sorts:
created: created:
id: created id: created
table: views_test_data table: views_test_data
field: created field: created
plugin_id: date
order: DESC order: DESC
plugin_id: date
title: 'Test serialize'
arguments: { } arguments: { }
style:
type: serializer
row:
type: data_field
query:
type: views_query
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_interface'
- request_format
- url.query_args
- user.permissions
tags: { }
rest_export_1: rest_export_1:
display_plugin: rest_export
id: rest_export_1 id: rest_export_1
display_title: serializer display_title: serializer
display_plugin: rest_export
position: null position: null
display_options: display_options:
defaults:
access: false
style: false
row: false
path: test/serialize/field
access: access:
type: none type: none
style: style:
type: serializer type: serializer
row: row:
type: data_field type: data_field
defaults:
access: false
style: false
row: false
display_extenders: { }
path: test/serialize/field
cache_metadata:
max-age: -1
contexts:
- 'languages:language_interface'
- request_format
tags: { }
rest_export_2: rest_export_2:
display_plugin: rest_export
id: rest_export_2 id: rest_export_2
display_title: 'serialize - access denied' display_title: 'serialize - access denied'
display_plugin: rest_export
position: null position: null
display_options: display_options:
defaults:
access: false
style: false
row: false
path: test/serialize/denied
access: access:
type: perm type: perm
options: options:
...@@ -118,16 +107,3 @@ display: ...@@ -118,16 +107,3 @@ display:
type: serializer type: serializer
row: row:
type: data_field type: data_field
defaults:
access: false
style: false
row: false
display_extenders: { }
path: test/serialize/denied
cache_metadata:
max-age: -1
contexts:
- 'languages:language_interface'
- request_format
- user.permissions
tags: { }
...@@ -107,7 +107,6 @@ public function getHandler(array $item, ?string $override_plugin_id = NULL): Vie ...@@ -107,7 +107,6 @@ public function getHandler(array $item, ?string $override_plugin_id = NULL): Vie
} }
} }
// First priority is to use the override.
// When aggregation is enabled, particular plugins need to be // When aggregation is enabled, particular plugins need to be
// replaced in order to override the query with a query that // replaced in order to override the query with a query that
// can run the aggregate counts, sums, or averages for example. // can run the aggregate counts, sums, or averages for example.
...@@ -115,24 +114,13 @@ public function getHandler(array $item, ?string $override_plugin_id = NULL): Vie ...@@ -115,24 +114,13 @@ public function getHandler(array $item, ?string $override_plugin_id = NULL): Vie
// for example which aggressively overrides any filter used // for example which aggressively overrides any filter used
// by a number of mathematical-type queries regardless of the // by a number of mathematical-type queries regardless of the
// original filter. // original filter.
if ($override_plugin_id) { $plugin_id = $override_plugin_id ?: $definition['id'];
$handler = $this->createInstance($override_plugin_id, $definition); // Try to use the overridden handler.
if (!method_exists($handler, 'broken') || !$handler->broken()) { $handler = $this->createInstance($plugin_id, $definition);
return $handler; if ($override_plugin_id && method_exists($handler, 'broken') && $handler->broken()) {
} $handler = $this->createInstance($definition['id'], $definition);
} }
return $handler;
// Then try the configuration provided for the handler.
if (isset($item['plugin_id'])) {
$handler = $this->createInstance($item['plugin_id'], $definition);
if (!method_exists($handler, 'broken') || !$handler->broken()) {
return $handler;
}
}
// Finally, fall back to the default configuration suggested
// by the view data.
return $this->createInstance($definition['id'], $definition);
} }
// Finally, use the 'broken' handler. // Finally, use the 'broken' handler.
......
...@@ -35,7 +35,7 @@ display: ...@@ -35,7 +35,7 @@ display:
field: type field: type
id: type id: type
table: node_field_data table: node_field_data
plugin_id: bundle plugin_id: in_operator
entity_type: node entity_type: node
entity_field: type entity_field: type
pager: pager:
......
...@@ -35,7 +35,7 @@ display: ...@@ -35,7 +35,7 @@ display:
field: type field: type
id: type id: type
table: node_field_data table: node_field_data
plugin_id: bundle plugin_id: in_operator
entity_type: node entity_type: node
entity_field: type entity_field: type
pager: pager:
......
langcode: en langcode: en
status: true status: true
dependencies: dependencies: { }
module:
- user
- views_test_data
id: test_click_sort id: test_click_sort
label: test_click_sort label: test_click_sort
module: views module: views
description: '' description: ''
tag: '' tag: ''
base_table: views_test_data base_table: views_test_data
base_field: id base_field: nid
display: display:
default: default:
id: default
display_title: Default
display_plugin: default
position: null
display_options: display_options:
fields: fields:
id: id:
id: id id: id
table: views_test_data table: views_test_data
field: id field: id
plugin_id: numeric
label: ID label: ID
plugin_id: numeric
name: name:
id: name id: name
table: views_test_data table: views_test_data
field: name field: name
label: Name
plugin_id: string plugin_id: string
label: ''
created: created:
id: created id: created
table: views_test_data table: views_test_data
field: created field: created
plugin_id: date label: created
date_format: timestamp plugin_id: field
custom_date_format: '' type: timestamp
timezone: '' settings:
date_format: medium
custom_date_format: ''
timezone: ''
access: access:
type: none type: none
cache: cache:
...@@ -55,17 +51,14 @@ display: ...@@ -55,17 +51,14 @@ display:
default_sort_order: desc default_sort_order: desc
created: created:
sortable: false sortable: false
cache_metadata: display_plugin: default
max-age: -1 display_title: Default
contexts: id: default
- 'languages:language_interface'
- url.query_args
- user.permissions
tags: { }
page_1:
id: page_1
display_title: Page
display_plugin: page
position: 0 position: 0
page_1:
display_options: display_options:
path: test_click_sort path: test_click_sort
display_plugin: page
display_title: Page
id: page_1
position: 0
langcode: en langcode: en
status: true status: true
dependencies: dependencies: { }
module:
- views_test_data
id: test_click_sort_ajax id: test_click_sort_ajax
label: test_click_sort_ajax label: test_click_sort_ajax
module: views module: views
description: '' description: ''
tag: '' tag: ''
base_table: views_test_data base_table: views_test_data
base_field: id base_field: nid
display: display:
default: default:
id: default
display_title: Default
display_plugin: default
position: null
display_options: display_options:
use_ajax: true
fields: fields:
id: id:
id: id id: id
table: views_test_data table: views_test_data
field: id field: id
plugin_id: numeric
label: ID label: ID
plugin_id: numeric
name: name:
id: name id: name
table: views_test_data table: views_test_data
field: name field: name
relationship: none
group_type: group
admin_label: ''
plugin_id: string
label: Name label: Name
exclude: false plugin_id: string
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
created: created:
id: created id: created
table: views_test_data table: views_test_data
field: created field: created
plugin_id: date label: created
date_format: timestamp plugin_id: field
custom_date_format: '' type: timestamp
timezone: '' settings:
pager: date_format: medium
type: mini custom_date_format: ''
options: timezone: ''
offset: 0
pagination_heading_level: h4
items_per_page: 1
total_pages: null
id: 0
tags:
next: 'Next ›'
previous: ' Previous'
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
access: access:
type: none type: none
cache: cache:
...@@ -107,61 +43,23 @@ display: ...@@ -107,61 +43,23 @@ display:
style: style:
type: table type: table
options: options:
grouping: { }
row_class: ''
default_row_class: true
columns:
id: id
name: name
created: created
default: id
info: info:
id: id:
sortable: false sortable: true
default_sort_order: asc default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
name: name:
sortable: true sortable: true
default_sort_order: desc default_sort_order: desc
align: ''
separator: ''
empty_column: false
responsive: ''
created: created:
sortable: false sortable: false
default_sort_order: asc display_plugin: default
align: '' display_title: Default
separator: '' id: default
empty_column: false
responsive: ''
override: true
sticky: false
summary: ''
empty_table: false
caption: ''
description: ''
use_ajax: true
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_interface'
- url.query_args
tags: { }
page_1:
id: page_1
display_title: Page
display_plugin: page
position: 0 position: 0
page_1:
display_options: display_options:
display_extenders: { }
path: test_click_sort path: test_click_sort
cache_metadata: display_plugin: page
max-age: -1 display_title: Page
contexts: id: page_1
- 'languages:language_interface' position: 0
- url.query_args
tags: { }
...@@ -86,7 +86,7 @@ display: ...@@ -86,7 +86,7 @@ display:
exclude: false exclude: false
entity_type: entity_test entity_type: entity_test
entity_field: test_text_access entity_field: test_text_access
plugin_id: field plugin_id: standard
empty: '' empty: ''
hide_empty: false hide_empty: false
empty_zero: false empty_zero: false
......
langcode: en langcode: en
status: true status: true
dependencies: dependencies:
config:
- core.entity_view_mode.node.teaser
module: module:
- node - node
id: test_exposed_block id: test_exposed_block
...@@ -14,83 +12,66 @@ base_table: node_field_data ...@@ -14,83 +12,66 @@ base_table: node_field_data
base_field: nid base_field: nid
display: display:
default: default:
id: default
display_title: Default
display_plugin: default
position: 0
display_options: display_options:
title: 'Test Exposed Block' title: 'Test Exposed Block'
pager:
type: full
exposed_form:
type: basic
options:
reset_button: true
access: access:
type: none type: none
cache: cache:
type: tag type: tag
exposed_form:
options:
reset_button: true
type: basic
filters: filters:
type: type:
expose:
identifier: type
label: 'Content: Type'
operator_id: type_op
reduce: false
exposed: true
field: type
id: type id: type
table: node_field_data table: node_field_data
field: type plugin_id: in_operator
entity_type: node entity_type: node
entity_field: type entity_field: type
plugin_id: bundle pager:
exposed: true type: full
expose: query:
operator_id: type_op options:
label: 'Content: Type' query_comment: ''
identifier: type type: views_query
reduce: false
style: style:
type: default type: default
row: row:
type: 'entity:node' type: 'entity:node'
query: display_plugin: default
type: views_query display_title: Default
options: id: default
query_comment: '' position: 0
display_extenders: { } page_1:
cache_metadata: display_options:
max-age: -1 path: test_exposed_block
contexts: exposed_block: true
- 'languages:language_interface' display_plugin: page
- url display_title: Page
- url.query_args id: page_1
- 'user.node_grants:view' position: 0
tags: { }
block_1: block_1:
display_plugin: block
id: block_1 id: block_1
display_title: Block display_title: Block
display_plugin: block
position: 2 position: 2
display_options: display_options:
exposed_block: true
display_extenders: { } display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
tags: { }
page_1:
id: page_1
display_title: Page
display_plugin: page
position: 0
display_options:
exposed_block: true exposed_block: true
display_extenders: { }
path: test_exposed_block
cache_metadata: cache_metadata:
max-age: -1 max-age: -1
contexts: contexts:
- 'languages:language_content'
- 'languages:language_interface' - 'languages:language_interface'
- url
- url.query_args - url.query_args
- 'user.node_grants:view' - 'user.node_grants:view'
- user.permissions
tags: { } tags: { }
langcode: en langcode: en
status: true status: true
dependencies: dependencies:
config:
- core.entity_view_mode.node.teaser
module: module:
- node - node
id: test_exposed_form_buttons id: test_exposed_form_buttons
...@@ -14,66 +12,48 @@ base_table: node_field_data ...@@ -14,66 +12,48 @@ base_table: node_field_data
base_field: nid base_field: nid
display: display:
default: default:
id: default
display_title: Default
display_plugin: default
position: 0
display_options: display_options:
pager:
type: full
exposed_form:
type: basic
options:
reset_button: true
access: access:
type: none type: none
cache: cache:
type: tag type: tag
exposed_form:
options:
reset_button: true
type: basic
filters: filters:
type: type:
expose:
identifier: type
label: 'Content: Type'
operator_id: type_op
reduce: false
description: 'Exposed description'
exposed: true
field: type
id: type id: type
table: node_field_data table: node_field_data
field: type plugin_id: in_operator
entity_type: node entity_type: node
entity_field: type entity_field: type
plugin_id: bundle pager:
exposed: true type: full
expose: query:
operator_id: type_op options:
label: 'Content: Type' query_comment: ''
description: 'Exposed description' type: views_query
identifier: type
reduce: false
style: style:
type: default type: default
row: row:
type: 'entity:node' type: 'entity:node'
query: display_plugin: default
type: views_query display_title: Default
options: id: default
query_comment: ''
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
tags: { }
page_1:
id: page_1
display_title: Page
display_plugin: page
position: 0 position: 0
page_1:
display_options: display_options:
display_extenders: { }
path: test_exposed_form_buttons path: test_exposed_form_buttons
cache_metadata: display_plugin: page
max-age: -1 display_title: Page
contexts: id: page_1
- 'languages:language_interface' position: 0
- url
- url.query_args
- 'user.node_grants:view'
tags: { }
...@@ -2,8 +2,7 @@ langcode: en ...@@ -2,8 +2,7 @@ langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- core.entity_view_mode.node.teaser - taxonomy.vocabulary.test_exposed_checkboxes
- taxonomy.vocabulary.tags
module: module:
- node - node
- taxonomy - taxonomy
...@@ -16,44 +15,33 @@ base_table: node_field_data ...@@ -16,44 +15,33 @@ base_table: node_field_data
base_field: nid base_field: nid
display: display:
default: default:
id: default
display_title: Default
display_plugin: default
position: 0
display_options: display_options:
pager:
type: full
exposed_form:
type: basic
options:
reset_button: true
access: access:
type: none type: none
cache: cache:
type: tag type: tag
exposed_form:
options:
reset_button: true
type: basic
filters: filters:
type_1: type:
id: type_1 id: type
table: node_field_data table: node_field_data
field: type field: type
relationship: none relationship: none
group_type: group group_type: group
admin_label: '' admin_label: ''
entity_type: node
entity_field: type
plugin_id: bundle
operator: in operator: in
value: { } value: { }
group: 1 group: 1
exposed: true exposed: true
expose: expose:
operator_id: type_1_op operator_id: type_op
label: 'Content type' label: 'Content: Type'
description: '' description: 'Exposed description'
use_operator: false use_operator: false
operator: type_1_op operator: ''
operator_limit_selection: false
operator_list: { }
identifier: type identifier: type
required: false required: false
remember: false remember: false
...@@ -73,6 +61,9 @@ display: ...@@ -73,6 +61,9 @@ display:
default_group: All default_group: All
default_group_multiple: { } default_group_multiple: { }
group_items: { } group_items: { }
plugin_id: in_operator
entity_type: node
entity_field: type
tid: tid:
id: tid id: tid
table: taxonomy_index table: taxonomy_index
...@@ -80,7 +71,6 @@ display: ...@@ -80,7 +71,6 @@ display:
relationship: none relationship: none
group_type: group group_type: group
admin_label: '' admin_label: ''
plugin_id: taxonomy_index_tid
operator: and operator: and
value: { } value: { }
group: 1 group: 1
...@@ -91,8 +81,6 @@ display: ...@@ -91,8 +81,6 @@ display:
description: '' description: ''
use_operator: false use_operator: false
operator: tid_op operator: tid_op
operator_limit_selection: false
operator_list: { }
identifier: tid identifier: tid
required: false required: false
remember: false remember: false
...@@ -113,45 +101,50 @@ display: ...@@ -113,45 +101,50 @@ display:
default_group_multiple: { } default_group_multiple: { }
group_items: { } group_items: { }
reduce_duplicates: false reduce_duplicates: false
vid: tags
type: select type: select
hierarchy: false
limit: true limit: true
vid: test_exposed_checkboxes
hierarchy: false
error_message: true error_message: true
filter_groups: plugin_id: taxonomy_index_tid
operator: AND pager:
groups: type: full
1: AND query:
options:
query_comment: ''
type: views_query
style: style:
type: default type: default
row: row:
type: 'entity:node' type: 'entity:node'
query:
type: views_query
options:
query_comment: ''
display_extenders: { } display_extenders: { }
display_plugin: default
display_title: Default
id: default
position: 0
cache_metadata: cache_metadata:
max-age: -1 max-age: -1
contexts: contexts:
- 'languages:language_interface' - 'languages:language_interface'
- url - url
- url.query_args - url.query_args
- user
- 'user.node_grants:view' - 'user.node_grants:view'
tags: { } tags: { }
page_1: page_1:
id: page_1
display_title: Page
display_plugin: page
position: 0
display_options: display_options:
display_extenders: { }
path: test_exposed_form_checkboxes path: test_exposed_form_checkboxes
display_extenders: { }
display_plugin: page
display_title: Page
id: page_1
position: 0
cache_metadata: cache_metadata:
max-age: -1 max-age: -1
contexts: contexts:
- 'languages:language_interface' - 'languages:language_interface'
- url - url
- url.query_args - url.query_args
- user
- 'user.node_grants:view' - 'user.node_grants:view'
tags: { } tags: { }
...@@ -60,7 +60,7 @@ display: ...@@ -60,7 +60,7 @@ display:
default_group: All default_group: All
default_group_multiple: { } default_group_multiple: { }
group_items: { } group_items: { }
plugin_id: bundle plugin_id: in_operator
entity_type: node entity_type: node
entity_field: type entity_field: type
created: created:
......
...@@ -63,7 +63,7 @@ display: ...@@ -63,7 +63,7 @@ display:
field: type field: type
id: type id: type
table: node_field_data table: node_field_data
plugin_id: bundle plugin_id: in_operator
entity_type: node entity_type: node
entity_field: type entity_field: type
nid: nid:
......
...@@ -188,7 +188,8 @@ display: ...@@ -188,7 +188,8 @@ display:
group_type: group group_type: group
admin_label: '' admin_label: ''
operator: '=' operator: '='
value: '' value:
value: ''
group: 1 group: 1
exposed: false exposed: false
expose: expose:
...@@ -215,7 +216,7 @@ display: ...@@ -215,7 +216,7 @@ display:
default_group: All default_group: All
default_group_multiple: { } default_group_multiple: { }
group_items: { } group_items: { }
plugin_id: history_user_timestamp plugin_id: date
defaults: defaults:
filters: false filters: false
filter_groups: false filter_groups: false
......
...@@ -40,7 +40,7 @@ display: ...@@ -40,7 +40,7 @@ display:
admin_label: '' admin_label: ''
entity_type: node entity_type: node
entity_field: type entity_field: type
plugin_id: bundle plugin_id: in_operator
operator: in operator: in
value: { } value: { }
group: 1 group: 1
......
<?php
declare(strict_types=1);
namespace Drupal\views_test_data_alter\Hook;
use Drupal\Core\Hook\Attribute\Hook;
/**
* Hook implementations for views_test_data_alter.
*/
class ViewsTestDataAlterHooks {
/**
* Implements hook_views_data_alter().
*/
#[Hook('views_data_alter')]
public function viewsDataAlter(array &$data): void {
// Modify a filter to use a different filter handler plugin
// by default so that we can test that the handler used
// respects the handler plugin ID specified in the
// configuration.
$data['node_field_data']['status']['filter']['id'] = 'numeric';
}
}
name: 'Views Test Data Alter'
type: module
description: 'Test module for Views to alter data.'
package: Testing
version: VERSION
dependencies:
- drupal:views
...@@ -39,6 +39,15 @@ class BaseFieldAccessTest extends ViewTestBase { ...@@ -39,6 +39,15 @@ class BaseFieldAccessTest extends ViewTestBase {
protected function setUp($import_test_views = TRUE, $modules = ['views_test_config', 'comment_test_views']): void { protected function setUp($import_test_views = TRUE, $modules = ['views_test_config', 'comment_test_views']): void {
parent::setUp($import_test_views, $modules); parent::setUp($import_test_views, $modules);
\Drupal::state()->set('entity_test.views_data', [
'entity_test' => [
'test_text_access' => [
'field' => [
'id' => 'standard',
],
],
],
]);
$entity_1 = EntityTest::create([ $entity_1 = EntityTest::create([
'test_text_access' => 'no access value', 'test_text_access' => 'no access value',
]); ]);
......
...@@ -333,12 +333,6 @@ public function testSetRelationship(): void { ...@@ -333,12 +333,6 @@ public function testSetRelationship(): void {
* @see \Drupal\views\Plugin\views\HandlerBase::placeholder() * @see \Drupal\views\Plugin\views\HandlerBase::placeholder()
*/ */
public function testPlaceholder(): void { public function testPlaceholder(): void {
// Change the test view to use the test field plugin which has the
// additional get placeholder method.
$config = $this->config('views.view.test_view');
$config->set('display.default.display_options.fields.name.plugin_id', 'test_field');
$config->save();
$view = Views::getView('test_view'); $view = Views::getView('test_view');
$view->initHandlers(); $view->initHandlers();
$view->initQuery(); $view->initQuery();
...@@ -348,7 +342,7 @@ public function testPlaceholder(): void { ...@@ -348,7 +342,7 @@ public function testPlaceholder(): void {
$field = $handler->field; $field = $handler->field;
$string = ':' . $table . '_' . $field; $string = ':' . $table . '_' . $field;
// Make sure the placeholder variables contain the expected values. // Make sure the placeholder variables are like expected.
$this->assertEquals($string, $handler->getPlaceholder()); $this->assertEquals($string, $handler->getPlaceholder());
$this->assertEquals($string . 1, $handler->getPlaceholder()); $this->assertEquals($string . 1, $handler->getPlaceholder());
$this->assertEquals($string . 2, $handler->getPlaceholder()); $this->assertEquals($string . 2, $handler->getPlaceholder());
...@@ -375,7 +369,7 @@ public function testAccess(): void { ...@@ -375,7 +369,7 @@ public function testAccess(): void {
$views_data = $this->viewsData(); $views_data = $this->viewsData();
$views_data = $views_data['views_test_data']; $views_data = $views_data['views_test_data'];
// Enable access only to the callback field and deny access for the callback and the arguments. // Enable access to callback only field and deny for callback + arguments.
$this->config('views_test_data.tests')->set('handler_access_callback', TRUE)->save(); $this->config('views_test_data.tests')->set('handler_access_callback', TRUE)->save();
$this->config('views_test_data.tests')->set('handler_access_callback_argument', FALSE)->save(); $this->config('views_test_data.tests')->set('handler_access_callback_argument', FALSE)->save();
$view->initDisplay(); $view->initDisplay();
...@@ -388,7 +382,7 @@ public function testAccess(): void { ...@@ -388,7 +382,7 @@ public function testAccess(): void {
} }
} }
// Enable access to the callback and the argument handlers and deny access for the callback. // Enable access to the callback + argument handlers and deny for callback.
$this->config('views_test_data.tests')->set('handler_access_callback', FALSE)->save(); $this->config('views_test_data.tests')->set('handler_access_callback', FALSE)->save();
$this->config('views_test_data.tests')->set('handler_access_callback_argument', TRUE)->save(); $this->config('views_test_data.tests')->set('handler_access_callback_argument', TRUE)->save();
$view->destroy(); $view->destroy();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment