e598e8c0893e03722e086f9850860268e12c9c2a
[yaffs-website] / web / core / lib / Drupal / Core / Entity / EntityChangesDetectionTrait.php
1 <?php
2
3 namespace Drupal\Core\Entity;
4
5 /**
6  * Provides helper methods to detect changes in an entity object.
7  *
8  * @internal This may be replaced by a proper entity comparison handler.
9  */
10 trait EntityChangesDetectionTrait {
11
12   /**
13    * Returns an array of field names to skip when checking for changes.
14    *
15    * @param \Drupal\Core\Entity\ContentEntityInterface $entity
16    *   A content entity object.
17    *
18    * @return string[]
19    *   An array of field names.
20    */
21   protected function getFieldsToSkipFromTranslationChangesCheck(ContentEntityInterface $entity) {
22     /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
23     $entity_type = $entity->getEntityType();
24
25     // A list of known revision metadata fields which should be skipped from
26     // the comparision.
27     $fields = [
28       $entity_type->getKey('revision'),
29       $entity_type->getKey('revision_translation_affected'),
30     ];
31     $fields = array_merge($fields, array_values($entity_type->getRevisionMetadataKeys()));
32
33     return $fields;
34   }
35
36 }