You are here

protected function EntityParser::getFieldsIrrelevantForDiff in Entity Share 8.3

Helper: lists entity properties/fields which should not appear in Diff.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The Drupal entity (local or remote).

Return value

string[] Array of entity properties/fields.

1 call to EntityParser::getFieldsIrrelevantForDiff()
EntityParser::parseEntity in modules/entity_share_diff/src/Service/EntityParser.php
Parses an entity.

File

modules/entity_share_diff/src/Service/EntityParser.php, line 339

Class

EntityParser
Entity parser.

Namespace

Drupal\entity_share_diff\Service

Code

protected function getFieldsIrrelevantForDiff(ContentEntityInterface $entity) {

  // Entity keys.
  $entity_keys = $entity
    ->getEntityType()
    ->getKeys();

  // Label and language code should be displayed in the Diff.
  unset($entity_keys['label']);
  unset($entity_keys['langcode']);
  $field_names = array_values($entity_keys);

  // Revision keys.
  $revision_keys = array_keys($entity
    ->getEntityType()
    ->getRevisionMetadataKeys());
  $field_names = array_merge($field_names, $revision_keys);

  // Other keys.
  $other_keys = [
    'changed',
    'created',
    // Related to translation.
    'content_translation_source',
    'content_translation_affected',
    'content_translation_outdated',
    'revision_translation_affected',
    // Related to paragraphs.
    'parent_id',
    'parent_type',
    'parent_field_name',
    // For some reason getRevisionMetadataKeys() doesn't always return these.
    'revision_timestamp',
    'revision_log',
  ];
  $field_names = array_merge($field_names, $other_keys);
  return $field_names;
}