diff --git a/core/modules/field/src/Views/FieldAPIHandlerTrait.php b/core/modules/field/src/Views/FieldAPIHandlerTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..da551cb464cd0f58dd04c5eccd13a9acb79087b1 --- /dev/null +++ b/core/modules/field/src/Views/FieldAPIHandlerTrait.php @@ -0,0 +1,79 @@ +fieldDefinition) { + $field_storage_config = $this->getFieldStorageDefinition(); + $this->fieldDefinition = BaseFieldDefinition::createFromFieldStorageDefinition($field_storage_config); + } + return $this->fieldDefinition; + } + + /** + * Gets the field storage configuration. + * + * @return \Drupal\field\FieldStorageConfigInterface + * The field storage definition used by this handler + */ + protected function getFieldStorageDefinition() { + if (!$this->fieldStorageDefinition) { + $field_storage_definitions = $this->getEntityManager()->getFieldStorageDefinitions($this->definition['entity_type']); + $this->fieldStorageDefinition = $field_storage_definitions[$this->definition['field_name']]; + } + return $this->fieldStorageDefinition; + } + + /** + * Returns the entity manager. + * + * @return \Drupal\Core\Entity\EntityManagerInterface + * The entity manager service. + */ + protected function getEntityManager() { + if (!isset($this->entityManager)) { + $this->entityManager = \Drupal::entityManager(); + } + return $this->entityManager; + } + +} diff --git a/core/modules/options/config/schema/options.schema.yml b/core/modules/options/config/schema/options.schema.yml index 9ccc7a4723e119ba9d4ac17e8441d6c9c30e3be5..7bd75478e19ee42893cbc6e104259cc252bb7486 100644 --- a/core/modules/options/config/schema/options.schema.yml +++ b/core/modules/options/config/schema/options.schema.yml @@ -114,3 +114,44 @@ field.widget.settings.options_buttons: field.widget.settings.options_select: type: mapping label: 'Select list format settings' + +views.argument.number_list_field: + type: views.argument.numeric + mapping: + summary: + type: mapping + label: 'Display a summary' + mapping: + sort_order: + type: string + label: 'Sort order' + number_of_records: + type: integer + label: 'Sort by' + format: + type: string + label: 'Format' + human: + type: boolean + +views.argument.string_list_field: + type: views.argument.string + mapping: + summary: + type: mapping + label: 'Display a summary' + mapping: + sort_order: + type: string + label: 'Sort order' + number_of_records: + type: integer + label: 'Sort by' + format: + type: string + label: 'Format' + human: + type: boolean + +views.filter.list_field: + type: views.filter.many_to_one diff --git a/core/modules/options/options.views.inc b/core/modules/options/options.views.inc new file mode 100644 index 0000000000000000000000000000000000000000..95b8474c205267de3dcb87145caf2c2e3eb4ac48 --- /dev/null +++ b/core/modules/options/options.views.inc @@ -0,0 +1,43 @@ +getSetting('allowed_values_function'); + // If this field makes use of dynamic allowed options, we ignore the views + // setting. + if (!empty($function)) { + return $data; + } + foreach ($data as $table_name => $table_data) { + foreach ($table_data as $field_name => $field_data) { + if (isset($field_data['filter']) && $field_name != 'delta') { + $data[$table_name][$field_name]['filter']['id'] = 'list_field'; + } + if (isset($field_data['argument']) && $field_name != 'delta') { + if ($field->type == 'list_string') { + $data[$table_name][$field_name]['argument']['id'] = 'string_list_field'; + } + else { + $data[$table_name][$field_name]['argument']['id'] = 'number_list_field'; + } + } + } + } + + return $data; +} diff --git a/core/modules/options/src/Plugin/views/argument/NumberListField.php b/core/modules/options/src/Plugin/views/argument/NumberListField.php new file mode 100644 index 0000000000000000000000000000000000000000..9a3f9d3ed30621c742ce39eabc2b4b13108c964d --- /dev/null +++ b/core/modules/options/src/Plugin/views/argument/NumberListField.php @@ -0,0 +1,91 @@ +getFieldStorageDefinition(); + $this->allowedValues = options_allowed_values($field_storage); + } + + /** + * {@inheritdoc} + */ + protected function defineOptions() { + $options = parent::defineOptions(); + $options['summary']['contains']['human'] = ['default' => FALSE]; + + return $options; + } + + /** + * {@inheritdoc} + */ + public function buildOptionsForm(&$form, FormStateInterface $form_state) { + parent::buildOptionsForm($form, $form_state); + + $form['summary']['human'] = [ + '#title' => $this->t('Display list value as human readable'), + '#type' => 'checkbox', + '#default_value' => $this->options['summary']['human'], + '#states' => [ + 'visible' => [ + ':input[name="options[default_action]"]' => ['value' => 'summary'], + ], + ], + ]; + } + + /** + * {@inheritdoc} + */ + public function summaryName($data) { + $value = $data->{$this->name_alias}; + // If the list element has a human readable name show it. + if (isset($this->allowedValues[$value]) && !empty($this->options['summary']['human'])) { + return $this->fieldFilterXss($this->allowedValues[$value]); + } + // Else, fallback to the key. + else { + return String::checkPlain($value); + } + } + +} diff --git a/core/modules/options/src/Plugin/views/argument/StringListField.php b/core/modules/options/src/Plugin/views/argument/StringListField.php new file mode 100644 index 0000000000000000000000000000000000000000..17189385218dbe63c79fce6bedd154ac5f4e0c31 --- /dev/null +++ b/core/modules/options/src/Plugin/views/argument/StringListField.php @@ -0,0 +1,91 @@ +getFieldStorageDefinition(); + $this->allowedValues = options_allowed_values($field_storage); + } + + /** + * {@inheritdoc} + */ + protected function defineOptions() { + $options = parent::defineOptions(); + + $options['summary']['contains']['human'] = ['default' => FALSE]; + + return $options; + } + + /** + * {@inheritdoc} + */ + public function buildOptionsForm(&$form, FormStateInterface $form_state) { + parent::buildOptionsForm($form, $form_state); + + $form['summary']['human'] = [ + '#title' => $this->t('Display list value as human readable'), + '#type' => 'checkbox', + '#default_value' => $this->options['summary']['human'], + '#states' => [ + 'visible' => [ + ':input[name="options[default_action]"]' => ['value' => 'summary'], + ], + ], + ]; + } + + /** + * {@inheritdoc} + */ + public function summaryName($data) { + $value = $data->{$this->name_alias}; + // If the list element has a human readable name show it. + if (isset($this->allowedValues[$value]) && !empty($this->options['summary']['human'])) { + return $this->caseTransform($this->fieldFilterXss($this->allowedValues[$value]), $this->options['case']); + } + // Else, fallback to the key. + else { + return $this->caseTransform(StringUtility::checkPlain($value), $this->options['case']); + } + } + +} diff --git a/core/modules/options/src/Plugin/views/filter/ListField.php b/core/modules/options/src/Plugin/views/filter/ListField.php new file mode 100644 index 0000000000000000000000000000000000000000..25fb2901a8cf7f857c0f9c99bd92509069b6d641 --- /dev/null +++ b/core/modules/options/src/Plugin/views/filter/ListField.php @@ -0,0 +1,37 @@ +getFieldStorageDefinition(); + // Set valueOptions here so getValueOptions() will just return it. + $this->valueOptions = options_allowed_values($field_storage); + } + +} diff --git a/core/modules/options/src/Tests/Views/OptionsListArgumentTest.php b/core/modules/options/src/Tests/Views/OptionsListArgumentTest.php new file mode 100644 index 0000000000000000000000000000000000000000..198ebd187b6ccd854891db9266f1db1a2317acf2 --- /dev/null +++ b/core/modules/options/src/Tests/Views/OptionsListArgumentTest.php @@ -0,0 +1,54 @@ +executeView($view, [1]); + + $resultset = [ + ['nid' => $this->nodes[0]->nid->value], + ['nid' => $this->nodes[1]->nid->value], + ]; + + $column_map = ['nid' => 'nid']; + $this->assertIdenticalResultset($view, $resultset, $column_map); + + $view = Views::getView('test_options_list_argument_string'); + $this->executeView($view, ['man', 'woman']); + + $resultset = [ + ['nid' => $this->nodes[0]->nid->value], + ['nid' => $this->nodes[1]->nid->value], + ]; + + $column_map = ['nid' => 'nid']; + $this->assertIdenticalResultset($view, $resultset, $column_map); + } + +} diff --git a/core/modules/options/src/Tests/Views/OptionsListFilterTest.php b/core/modules/options/src/Tests/Views/OptionsListFilterTest.php new file mode 100644 index 0000000000000000000000000000000000000000..164bf15ae2c4062d9a21193d3c629f6b856c4111 --- /dev/null +++ b/core/modules/options/src/Tests/Views/OptionsListFilterTest.php @@ -0,0 +1,43 @@ +executeView($view); + + $resultset = [ + ['nid' => $this->nodes[0]->nid->value], + ['nid' => $this->nodes[1]->nid->value], + ]; + + $column_map = ['nid' => 'nid']; + $this->assertIdenticalResultset($view, $resultset, $column_map); + } + +} diff --git a/core/modules/options/src/Tests/Views/OptionsTestBase.php b/core/modules/options/src/Tests/Views/OptionsTestBase.php new file mode 100644 index 0000000000000000000000000000000000000000..857885a396c1b3ce4b916ac98eb91ab4f11ed308 --- /dev/null +++ b/core/modules/options/src/Tests/Views/OptionsTestBase.php @@ -0,0 +1,125 @@ +mockStandardInstall(); + + ViewTestData::createTestViews(get_class($this), ['options_test_views']); + + $settings = []; + $settings['type'] = 'article'; + $settings['field_test_list_string'][]['value'] = $this->fieldValues[0]; + $settings['field_test_list_integer'][]['value'] = 0; + + $node = Node::create($settings); + $node->save(); + + $this->nodes[] = $node; + $node = $node->createDuplicate(); + $node->save(); + $this->nodes[] = $node; + } + + /** + * Provides a workaround for the inability to use the standard profile. + * + * @see http://drupal.org/node/1708692 + */ + protected function mockStandardInstall() { + $this->installEntitySchema('user'); + $this->installEntitySchema('node'); + + NodeType::create( + ['type' => 'article'] + )->save(); + $this->fieldValues = [ + $this->randomMachineName(), + $this->randomMachineName(), + ]; + + $this->fieldNames = ['field_test_list_string', 'field_test_list_integer']; + + // Create two field entities. + FieldStorageConfig::create([ + 'field_name' => $this->fieldNames[0], + 'entity_type' => 'node', + 'type' => 'list_string', + 'cardinality' => 1, + 'settings' => [ + 'allowed_values' => [ + $this->fieldValues[0] => $this->fieldValues[0], + $this->fieldValues[1] => $this->fieldValues[1], + ], + ], + ])->save(); + FieldStorageConfig::create([ + 'field_name' => $this->fieldNames[1], + 'entity_type' => 'node', + 'type' => 'list_integer', + 'cardinality' => 1, + 'settings' => [ + 'allowed_values' => [ + $this->fieldValues[0], + $this->fieldValues[1], + ], + ], + ])->save(); + foreach ($this->fieldNames as $field_name) { + FieldConfig::create([ + 'field_name' => $field_name, + 'entity_type' => 'node', + 'label' => 'Test options list field', + 'bundle' => 'article', + ])->save(); + } + } + +} diff --git a/core/modules/options/tests/options_test_views/options_test_views.info.yml b/core/modules/options/tests/options_test_views/options_test_views.info.yml new file mode 100644 index 0000000000000000000000000000000000000000..07d1cac8d831ef4f82b105e55b5042cbf9b0e932 --- /dev/null +++ b/core/modules/options/tests/options_test_views/options_test_views.info.yml @@ -0,0 +1,9 @@ +name: 'Options test views' +type: module +description: 'Provides default views for views options tests.' +package: Testing +version: VERSION +core: 8.x +dependencies: + - options + - views diff --git a/core/modules/options/tests/options_test_views/test_views/views.view.test_options_list_argument_numeric.yml b/core/modules/options/tests/options_test_views/test_views/views.view.test_options_list_argument_numeric.yml new file mode 100644 index 0000000000000000000000000000000000000000..69398b389527670de62f1988f859989075c49ea5 --- /dev/null +++ b/core/modules/options/tests/options_test_views/test_views/views.view.test_options_list_argument_numeric.yml @@ -0,0 +1,205 @@ +langcode: en +status: true +dependencies: + config: + - node.type.article + module: + - node + - user +id: test_options_list_argument_numeric +label: 'test options list argument (numeric)' +module: views +description: '' +tag: '' +base_table: node +base_field: nid +core: 8.x +display: + default: + display_plugin: default + id: default + display_title: Master + position: 1 + display_options: + access: + type: perm + options: + perm: 'access content' + cache: + type: none + options: { } + query: + type: views_query + options: + disable_sql_rewrite: false + distinct: false + replica: false + query_comment: false + query_tags: { } + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: false + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + pager: + type: some + options: + items_per_page: 5 + offset: 0 + style: + type: default + row: + type: fields + fields: + title: + id: title + table: node_field_data + field: title + label: '' + alter: + alter_text: false + make_link: false + absolute: false + trim: false + word_boundary: false + ellipsis: false + strip_tags: false + html: false + hide_empty: false + empty_zero: false + link_to_node: true + relationship: none + group_type: group + admin_label: '' + exclude: 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_alter_empty: true + plugin_id: node + filters: + status: + value: true + table: node_field_data + field: status + id: status + expose: + operator: '' + group: 1 + plugin_id: boolean + type: + id: type + table: node_field_data + field: type + relationship: none + group_type: group + admin_label: '' + operator: in + value: + article: article + group: 1 + exposed: false + expose: + operator_id: '0' + label: '' + description: '' + use_operator: false + operator: '' + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + plugin_id: bundle + sorts: + nid: + id: nid + table: nid + field: nid + order: DESC + relationship: none + group_type: group + admin_label: '' + exposed: false + expose: + label: '' + plugin_id: standard + title: 'test options list argument' + header: { } + footer: { } + empty: { } + relationships: { } + arguments: + field_test_list_integer_value: + id: field_test_list_integer_value + table: field_data_field_test_list_integer + field: field_test_list_integer_value + relationship: none + group_type: group + admin_label: '' + default_action: empty + exception: + value: all + title_enable: false + title: All + title_enable: false + title: '' + default_argument_type: fixed + default_argument_options: + argument: '' + default_argument_skip_url: false + summary_options: + base_path: '' + items_per_page: 25 + count: false + override: false + summary: + sort_order: asc + number_of_records: 0 + format: default_summary + human: true + specify_validation: false + validate: + type: none + fail: 'not found' + validate_options: { } + break_phrase: false + 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 + display_title: Block + position: 1 + display_options: + display_extenders: { } + field_langcode: '***LANGUAGE_language_content***' + field_langcode_add_to_query: null diff --git a/core/modules/options/tests/options_test_views/test_views/views.view.test_options_list_argument_string.yml b/core/modules/options/tests/options_test_views/test_views/views.view.test_options_list_argument_string.yml new file mode 100644 index 0000000000000000000000000000000000000000..ef09354f35c37338bf5da4e41aacfcd78842c48a --- /dev/null +++ b/core/modules/options/tests/options_test_views/test_views/views.view.test_options_list_argument_string.yml @@ -0,0 +1,204 @@ +langcode: en +status: true +dependencies: + config: + - node.type.article + module: + - node + - user +id: test_options_list_argument_string +label: 'test options list argument (string)' +module: views +description: '' +tag: '' +base_table: node +base_field: nid +core: 8.x +display: + default: + display_plugin: default + id: default + display_title: Master + position: 1 + display_options: + access: + type: perm + options: + perm: 'access content' + cache: + type: none + options: { } + query: + type: views_query + options: + disable_sql_rewrite: false + distinct: false + replica: false + query_comment: false + query_tags: { } + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: false + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + pager: + type: some + options: + items_per_page: 5 + offset: 0 + style: + type: default + row: + type: fields + fields: + title: + id: title + table: node_field_data + field: title + label: '' + alter: + alter_text: false + make_link: false + absolute: false + trim: false + word_boundary: false + ellipsis: false + strip_tags: false + html: false + hide_empty: false + empty_zero: false + link_to_node: true + relationship: none + group_type: group + admin_label: '' + exclude: 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_alter_empty: true + plugin_id: node + filters: + status: + value: true + table: node_field_data + field: status + id: status + expose: + operator: '' + group: 1 + plugin_id: boolean + type: + id: type + table: node_field_data + field: type + relationship: none + group_type: group + admin_label: '' + operator: in + value: + article: article + group: 1 + exposed: false + expose: + operator_id: '0' + label: '' + description: '' + use_operator: false + operator: '' + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + plugin_id: bundle + sorts: + nid: + id: nid + table: nid + field: nid + order: DESC + relationship: none + group_type: group + admin_label: '' + exposed: false + expose: + label: '' + plugin_id: standard + title: 'test options list argument' + header: { } + footer: { } + empty: { } + relationships: { } + arguments: + field_test_list_string_value: + id: field_test_list_string_value + table: field_data_field_test_list_string + field: field_test_list_string_value + relationship: none + group_type: group + admin_label: '' + default_action: empty + exception: + value: all + title_enable: false + title: All + title_enable: false + title: '' + default_argument_type: fixed + default_argument_options: + argument: '' + default_argument_skip_url: false + summary_options: + base_path: '' + items_per_page: 25 + count: false + override: false + summary: + sort_order: asc + number_of_records: 0 + format: default_summary + human: true + specify_validation: false + validate: + type: none + fail: 'not found' + validate_options: { } + 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 + display_title: Block + position: 1 + display_options: + display_extenders: { } + field_langcode: '***LANGUAGE_language_content***' + field_langcode_add_to_query: null diff --git a/core/modules/options/tests/options_test_views/test_views/views.view.test_options_list_filter.yml b/core/modules/options/tests/options_test_views/test_views/views.view.test_options_list_filter.yml new file mode 100644 index 0000000000000000000000000000000000000000..4da80eae7e42cd9e975430f9adf36d504f46b66e --- /dev/null +++ b/core/modules/options/tests/options_test_views/test_views/views.view.test_options_list_filter.yml @@ -0,0 +1,209 @@ +langcode: en +status: true +dependencies: + config: + - node.type.article + module: + - node + - user +id: test_options_list_filter +label: test_options_list_filter +module: views +description: '' +tag: '' +base_table: node +base_field: nid +core: 8.x +display: + default: + display_plugin: default + id: default + display_title: Master + position: 1 + display_options: + access: + type: perm + options: + perm: 'access content' + cache: + type: none + options: { } + query: + type: views_query + options: + disable_sql_rewrite: false + distinct: false + replica: false + query_comment: false + query_tags: { } + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: false + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + pager: + type: some + options: + items_per_page: 5 + offset: 0 + style: + type: default + row: + type: fields + fields: + title: + id: title + table: node_field_data + field: title + label: '' + alter: + alter_text: false + make_link: false + absolute: false + trim: false + word_boundary: false + ellipsis: false + strip_tags: false + html: false + hide_empty: false + empty_zero: false + link_to_node: true + relationship: none + group_type: group + admin_label: '' + exclude: 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_alter_empty: true + plugin_id: node + filters: + status: + value: true + table: node_field_data + field: status + id: status + expose: + operator: '' + group: 1 + plugin_id: boolean + field_test_list_string_value: + id: field_test_list_string_value + table: field_data_field_test_list_string + field: field_test_list_string_value + relationship: none + group_type: group + admin_label: '' + operator: or + value: + man: man + woman: woman + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + reduce_duplicates: false + plugin_id: list_field + type: + id: type + table: node_field_data + field: type + relationship: none + group_type: group + admin_label: '' + operator: in + value: + article: article + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + plugin_id: bundle + sorts: + nid: + id: nid + table: nid + field: nid + order: DESC + relationship: none + group_type: group + admin_label: '' + exposed: false + expose: + label: '' + plugin_id: standard + title: test_options_list_filter + header: { } + footer: { } + empty: { } + relationships: { } + arguments: { } + display_extenders: { } + field_langcode: '***LANGUAGE_language_content***' + field_langcode_add_to_query: null + block_1: + display_plugin: block + id: block_1 + display_title: Block + position: 1 + display_options: + display_extenders: { } + field_langcode: '***LANGUAGE_language_content***' + field_langcode_add_to_query: null diff --git a/core/modules/views/src/Plugin/views/field/Field.php b/core/modules/views/src/Plugin/views/field/Field.php index 05f633508db3ba30ffa2647bcf80cc1516ed71a4..1be60cef5d2bb84db3e2c0f8d58f13b0e77a9496 100644 --- a/core/modules/views/src/Plugin/views/field/Field.php +++ b/core/modules/views/src/Plugin/views/field/Field.php @@ -25,6 +25,7 @@ use Drupal\Core\Render\RendererInterface; use Drupal\Core\Session\AccountInterface; use Drupal\field\FieldStorageConfigInterface; +use Drupal\field\Views\FieldAPIHandlerTrait; use Drupal\views\Plugin\CacheablePluginInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase; @@ -45,6 +46,8 @@ */ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiItemsFieldHandlerInterface { + use FieldAPIHandlerTrait; + /** * An array to store field renderable arrays for use by renderItems(). * @@ -52,24 +55,6 @@ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiIt */ public $items = array(); - /** - * The field definition to use. - * - * A field storage definition turned into a field definition, so it can be - * used with widgets and formatters. See - * BaseFieldDefinition::createFromFieldStorageDefinition(). - * - * @var \Drupal\Core\Field\FieldDefinitionInterface - */ - protected $fieldDefinition; - - /** - * The field config. - * - * @var \Drupal\field\FieldStorageConfigInterface - */ - protected $fieldStorageConfig; - /** * Does the field supports multiple field values. * @@ -185,33 +170,6 @@ public static function create(ContainerInterface $container, array $configuratio ); } - /** - * Gets the field definition. - * - * @return \Drupal\Core\Field\FieldDefinitionInterface - * The field definition used by this handler. - */ - protected function getFieldDefinition() { - if (!$this->fieldDefinition) { - $field_storage_config = $this->getFieldStorageDefinition(); - $this->fieldDefinition = BaseFieldDefinition::createFromFieldStorageDefinition($field_storage_config); - } - return $this->fieldDefinition; - } - - /** - * Gets the field configuration. - * - * @return \Drupal\field\FieldStorageConfigInterface - */ - protected function getFieldStorageConfig() { - if (!$this->fieldStorageConfig) { - $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($this->definition['entity_type']); - $this->fieldStorageConfig = $field_storage_definitions[$this->definition['field_name']]; - } - return $this->fieldStorageConfig; - } - /** * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init(). */ diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php index 82dabe09a49fca98fedc9a452f6123c694bba05d..5d4865cc2b472c941585e72d24851da3c4d24a54 100644 --- a/core/modules/views/src/Plugin/views/filter/InOperator.php +++ b/core/modules/views/src/Plugin/views/filter/InOperator.php @@ -65,7 +65,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o */ public function getValueOptions() { if (isset($this->valueOptions)) { - return; + return $this->valueOptions; } if (isset($this->definition['options callback']) && is_callable($this->definition['options callback'])) { diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc index 5f866260a9f565d54fbb980ca5dff8b94e283276..1e91727b642b98a1c525c1787f929d02896806c5 100644 --- a/core/modules/views/views.views.inc +++ b/core/modules/views/views.views.inc @@ -634,26 +634,3 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora return $data; } - -/** - * Have a different filter handler for lists. This should allow to select values of the list. - */ -function list_field_views_data(FieldStorageConfigInterface $field_storage) { - $data = views_field_default_views_data($field_storage); - foreach ($data as $table_name => $table_data) { - foreach ($table_data as $field_name => $field_data) { - if (isset($field_data['filter']) && $field_name != 'delta') { - $data[$table_name][$field_name]['filter']['id'] = 'field_list'; - } - if (isset($field_data['argument']) && $field_name != 'delta') { - if ($field_storage->getType() == 'list_string') { - $data[$table_name][$field_name]['argument']['id'] = 'field_list_string'; - } - else { - $data[$table_name][$field_name]['argument']['id'] = 'field_list'; - } - } - } - } - return $data; -}