diff --git a/config/install/diff.plugins.yml b/config/install/diff.plugins.yml index 4a7fb90..e69de29 100644 --- a/config/install/diff.plugins.yml +++ b/config/install/diff.plugins.yml @@ -1,167 +0,0 @@ -block: - title: - type: core_field_diff_builder - -node: - title: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - file: - type: file_field_diff_builder - settings: - show_id: 1 - compare_description_field: 0 - compare_display_field: 0 - property_separator: nl - show_header: 1 - markdown: drupal_html_to_text - image: - type: image_field_diff_builder - settings: - show_id: 1 - compare_alt_field: 0 - compare_title_field: 0 - property_separator: nl - show_header: 1 - markdown: drupal_html_to_text - list_string: - type: list_field_diff_builder - settings: - compare: key - show_header: 1 - markdown: drupal_html_to_text - list_float: - type: list_field_diff_builder - settings: - compare: key - show_header: 1 - markdown: drupal_html_to_text - list_integer: - type: list_field_diff_builder - settings: - compare: key - show_header: 1 - markdown: drupal_html_to_text - path: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - taxonomy_term_reference: - type: term_reference_field_diff_builder - settings: - show_name: 1 - show_id: 0 - show_header: 1 - markdown: drupal_html_to_text - text: - type: text_field_diff_builder - settings: - compare_format: 0 - show_header: 1 - markdown: drupal_html_to_text - text_long: - type: text_field_diff_builder - settings: - compare_format: 0 - show_header: 1 - markdown: drupal_html_to_text - text_with_summary: - type: text_summary_field_diff_builder - settings: - compare_format: 0 - compare_summary: 0 - show_header: 1 - markdown: drupal_html_to_text - email: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - string_long: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - integer: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - created: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - string: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - changed: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - uuid: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - entity_reference: - type: entity_reference_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - compare_entity_reference: 1 - language: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - float: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - map: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - timestamp: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - boolean: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - uri: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - decimal: - type: core_field_diff_builder - settings: - show_header: 1 - markdown: drupal_html_to_text - link: - type: link_field_diff_builder - settings: - compare_title: 0 - compare_uri: 1 - show_header: 1 - markdown: drupal_html_to_text - comment: - type: comment_field_diff_builder - settings: - compare_key: 0 - compare_string: 1 - show_header: 1 - markdown: drupal_html_to_text diff --git a/config/install/diff.settings.yml b/config/install/diff.settings.yml index 467dcab..115bdff 100644 --- a/config/install/diff.settings.yml +++ b/config/install/diff.settings.yml @@ -2,22 +2,4 @@ general_settings: theme: default radio_behavior: simple context_lines_leading: 1 - context_lines_trailing: 1 -entity: - node: - nid: 0 - uuid: 0 - vid: 0 - type: 0 - langcode: 0 - title: 1 - uid: 0 - status: 0 - created: 0 - changed: 0 - promote: 0 - sticky: 0 - revision_timestamp: 0 - revision_uid: 0 - revision_log: 0 - path: 0 + context_lines_trailing: 1 \ No newline at end of file diff --git a/config/schema/diff.schema.yml b/config/schema/diff.schema.yml index d94e631..93065fc 100644 --- a/config/schema/diff.schema.yml +++ b/config/schema/diff.schema.yml @@ -40,7 +40,7 @@ diff.settings: diff.plugins: type: config_object - label: 'Entity type' + label: 'Field' mapping: fields: type: sequence diff --git a/diff.links.task.yml b/diff.links.task.yml index f11da6e..9a904c9 100644 --- a/diff.links.task.yml +++ b/diff.links.task.yml @@ -7,8 +7,3 @@ diff.fields_list: route_name: diff.fields_list base_route: diff.general_settings title: Configurable Fields - -diff.entities: - route_name: diff.node_settings - title: Base Fields - base_route: diff.general_settings diff --git a/src/Controller/GenericRevisionController.php b/src/Controller/GenericRevisionController.php index 00f08a9..c3240ee 100644 --- a/src/Controller/GenericRevisionController.php +++ b/src/Controller/GenericRevisionController.php @@ -90,22 +90,6 @@ class GenericRevisionController extends EntityComparisonBase { // Perform comparison only if both entity revisions loaded successfully. if ($left_revision != FALSE && $right_revision != FALSE) { $fields = $this->compareRevisions($left_revision, $right_revision); - $entity_base_fields = $this->entityManager()->getBaseFieldDefinitions($entity_type_id); - // Check to see if we need to display certain fields or not based on - // selected view mode display settings. - foreach ($fields as $field_name => $field) { - // If we are dealing with entities only compare those fields - // set as visible from the selected view mode. - $view_mode = $this->config->get('content_type_settings.' . $entity->bundle() . '.view_mode'); - // If no view mode is selected use the default view mode. - if ($view_mode == NULL) { - $view_mode = 'default'; - } - $visible = entity_get_display($entity_type_id, $entity->bundle(), $view_mode)->getComponent($field_name); - if ($visible == NULL && !array_key_exists($field_name, $entity_base_fields)) { - unset($fields[$field_name]); - } - } // Build the diff rows for each field and append the field rows // to the table rows. foreach ($fields as $field) { diff --git a/src/Controller/NodeRevisionController.php b/src/Controller/NodeRevisionController.php index 483ce91..4b5137f 100644 --- a/src/Controller/NodeRevisionController.php +++ b/src/Controller/NodeRevisionController.php @@ -72,22 +72,6 @@ class NodeRevisionController extends EntityComparisonBase { // Perform comparison only if both node revisions loaded successfully. if ($left_revision != FALSE && $right_revision != FALSE) { $fields = $this->compareRevisions($left_revision, $right_revision); - $node_base_fields = $this->entityManager()->getBaseFieldDefinitions('node'); - // Check to see if we need to display certain fields or not based on - // selected view mode display settings. - foreach ($fields as $field_name => $field) { - // If we are dealing with nodes only compare those fields - // set as visible from the selected view mode. - $view_mode = $this->config->get('content_type_settings.' . $node->getType() . '.view_mode'); - // If no view mode is selected use the default view mode. - if ($view_mode == NULL) { - $view_mode = 'default'; - } - $visible = entity_get_display('node', $node->getType(), $view_mode)->getComponent($field_name); - if ($visible == NULL && !array_key_exists($field_name, $node_base_fields)) { - //unset($fields[$field_name]); - } - } // Build the diff rows for each field and append the field rows // to the table rows. foreach ($fields as $field) { diff --git a/src/DiffEntityParser.php b/src/DiffEntityParser.php index c6f962e..f7e3734 100644 --- a/src/DiffEntityParser.php +++ b/src/DiffEntityParser.php @@ -77,13 +77,11 @@ class DiffEntityParser { $entity = $entity->getTranslation($langcode); } $entity_type_id = $entity->getEntityTypeId(); - // Load all entity base fields. - $entity_base_fields = $this->entityManager->getBaseFieldDefinitions($entity_type_id); // Loop through entity fields and transform every FieldItemList object // into an array of strings according to field type specific settings. foreach ($entity as $field_items) { $field_type = $field_items->getFieldDefinition()->getName(); - $plugin_config = $this->pluginsConfig->get('fields.' . $entity_type_id . '__' . $field_type); + $plugin_config = $this->pluginsConfig->get('fields.' . $entity_type_id . '.' . $field_type); $plugin = NULL; if ($plugin_config && $plugin_config['type'] != 'hidden') { $plugin = $this->diffBuilderManager->createInstance($plugin_config['type'], $plugin_config['settings']); @@ -92,11 +90,9 @@ class DiffEntityParser { // Configurable field. It is the responsibility of the class extending // this class to hide some configurable fields from comparison. This // class compares all configurable fields. - if (!array_key_exists($field_items->getName(), $entity_base_fields)) { - $build = $plugin->build($field_items); - if (!empty($build)) { - $result[$field_items->getName()] = $build; - } + $build = $plugin->build($field_items); + if (!empty($build)) { + $result[$field_items->getName()] = $build; } } } diff --git a/src/EntityComparisonBase.php b/src/EntityComparisonBase.php index 6c3e0a1..8f6f550 100644 --- a/src/EntityComparisonBase.php +++ b/src/EntityComparisonBase.php @@ -119,34 +119,34 @@ class EntityComparisonBase extends ControllerBase { foreach ($left_values as $field_name => $values) { $field_definition = $left_entity->getFieldDefinition($field_name); // Get the compare settings for this field type. - $compare_settings = $this->pluginsConfig->get('fields.' . $left_entity->getEntityTypeId() . '__' .$field_definition->getName()); - $result[$left_entity->getEntityTypeId() . '__' .$field_definition->getName()] = array( + $compare_settings = $this->pluginsConfig->get('fields.' . $left_entity->getEntityTypeId() . '.' .$field_definition->getName()); + $result[$left_entity->getEntityTypeId() . '.' .$field_definition->getName()] = array( '#name' => ($compare_settings['settings']['show_header'] == 1) ? $field_definition->getLabel() : '', '#settings' => $compare_settings, ); // Fields which exist on the right entity also. if (isset($right_values[$field_name])) { - $result[$left_entity->getEntityTypeId() . '__' . $field_definition->getName()] += $this->combineFields($left_values[$field_name], $right_values[$field_name]); + $result[$left_entity->getEntityTypeId() . '.' . $field_definition->getName()] += $this->combineFields($left_values[$field_name], $right_values[$field_name]); // Unset the field from the right entity so that we know if the right // entity has any fields that left entity doesn't have. unset($right_values[$field_name]); } // This field exists only on the left entity. else { - $result[$left_entity->getEntityTypeId() . '__' . $field_definition->getName()] += $this->combineFields($left_values[$field_name], array()); + $result[$left_entity->getEntityTypeId() . '.' . $field_definition->getName()] += $this->combineFields($left_values[$field_name], array()); } } // Fields which exist only on the right entity. foreach ($right_values as $field_name => $values) { $field_definition = $right_entity->getFieldDefinition($field_name); - $compare_settings = $this->pluginsConfig->get('fields.' . $right_entity->getEntityTypeId() . '__' .$field_definition->getName()); - $result[$right_entity->getEntityTypeId() . '__' .$field_definition->getName()] = array( + $compare_settings = $this->pluginsConfig->get('fields.' . $right_entity->getEntityTypeId() . '.' .$field_definition->getName()); + $result[$right_entity->getEntityTypeId() . '.' .$field_definition->getName()] = array( '#name' => ($compare_settings['settings']['show_header'] == 1) ? $field_definition->getLabel() : '', '#settings' => $compare_settings, ); - $result[$right_entity->getEntityTypeId() . '__' .$field_definition->getName()] += $this->combineFields(array(), $right_values[$field_name]); + $result[$right_entity->getEntityTypeId() . '.' .$field_definition->getName()] += $this->combineFields(array(), $right_values[$field_name]); } // Field rows. Recurse through all child elements. diff --git a/src/FieldDiffBuilderBase.php b/src/FieldDiffBuilderBase.php index ad0fb6d..5259779 100644 --- a/src/FieldDiffBuilderBase.php +++ b/src/FieldDiffBuilderBase.php @@ -117,7 +117,6 @@ abstract class FieldDiffBuilderBase extends PluginBase implements FieldDiffBuild public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['show_header'] = $form_state->getValue('show_header'); $this->configuration['markdown'] = $form_state->getValue('markdown'); - //$this->configuration['#field_type'] = $form_state->get('field_type'); $this->configuration['#fields'] = $form_state->get('fields'); $this->setConfiguration($this->configuration); $this->getConfiguration()->save(); diff --git a/src/Form/FieldsSettingsForm.php b/src/Form/FieldsSettingsForm.php index daad313..77a4058 100644 --- a/src/Form/FieldsSettingsForm.php +++ b/src/Form/FieldsSettingsForm.php @@ -135,7 +135,7 @@ class FieldsSettingsForm extends ConfigFormBase { continue; } - $key = $entity_type_name . '__' . $field_name; + $key = $entity_type_name . '.' . $field_name; // Build a row in the table for every field type. $form['fields'][$key] = $this->buildFieldRow($entity_type, $field_definition, $plugins, $diff_plugin_definitions, $form_state); } @@ -162,7 +162,7 @@ class FieldsSettingsForm extends ConfigFormBase { $field_name = $field_definition->getName();// Machine name $field_type = $field_definition->getType(); - $field_key = $entity_type->id() . '__' . $field_name; + $field_key = $entity_type->id() . '.' . $field_name; $display_options = $this->config->get('fields.' . $field_key); // Build a list of all diff plugins supporting the field type of the field.