Mercurial > hg > isophonics-drupal-site
annotate core/lib/Drupal/Core/Entity/EntityChangesDetectionTrait.php @ 15:e200cb7efeb3
Update Drupal core to 8.5.3 via Composer
author | Chris Cannam |
---|---|
date | Thu, 26 Apr 2018 11:26:54 +0100 |
parents | 1fec387a4317 |
children | 129ea1e6d783 |
rev | line source |
---|---|
Chris@14 | 1 <?php |
Chris@14 | 2 |
Chris@14 | 3 namespace Drupal\Core\Entity; |
Chris@14 | 4 |
Chris@14 | 5 /** |
Chris@14 | 6 * Provides helper methods to detect changes in an entity object. |
Chris@14 | 7 * |
Chris@14 | 8 * @internal This may be replaced by a proper entity comparison handler. |
Chris@14 | 9 */ |
Chris@14 | 10 trait EntityChangesDetectionTrait { |
Chris@14 | 11 |
Chris@14 | 12 /** |
Chris@14 | 13 * Returns an array of field names to skip when checking for changes. |
Chris@14 | 14 * |
Chris@14 | 15 * @param \Drupal\Core\Entity\ContentEntityInterface $entity |
Chris@14 | 16 * A content entity object. |
Chris@14 | 17 * |
Chris@14 | 18 * @return string[] |
Chris@14 | 19 * An array of field names. |
Chris@14 | 20 */ |
Chris@14 | 21 protected function getFieldsToSkipFromTranslationChangesCheck(ContentEntityInterface $entity) { |
Chris@14 | 22 /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */ |
Chris@14 | 23 $entity_type = $entity->getEntityType(); |
Chris@14 | 24 |
Chris@14 | 25 // A list of known revision metadata fields which should be skipped from |
Chris@14 | 26 // the comparision. |
Chris@14 | 27 $fields = [ |
Chris@14 | 28 $entity_type->getKey('revision'), |
Chris@14 | 29 $entity_type->getKey('revision_translation_affected'), |
Chris@14 | 30 ]; |
Chris@14 | 31 $fields = array_merge($fields, array_values($entity_type->getRevisionMetadataKeys())); |
Chris@14 | 32 |
Chris@14 | 33 return $fields; |
Chris@14 | 34 } |
Chris@14 | 35 |
Chris@14 | 36 } |