You are here

public function LingotekConfigTranslationService::hasEntityChanged in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  2. 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  3. 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  4. 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  5. 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  6. 3.3.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  7. 3.4.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  8. 3.5.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  9. 3.6.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  10. 3.7.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  11. 3.8.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()

Checks if the source entity data has changed from last time we uploaded it.

Parameters

ConfigEntityInterface &$entity: The entity being checked

Return value

boolean TRUE if the entity has changed, false if not.

Overrides LingotekConfigTranslationServiceInterface::hasEntityChanged

File

src/LingotekConfigTranslationService.php, line 286
Contains \Drupal\lingotek\LingotekConfigTranslationService.

Class

LingotekConfigTranslationService
Service for managing Lingotek configuration translations.

Namespace

Drupal\lingotek

Code

public function hasEntityChanged(ConfigEntityInterface &$entity) {
  $source_data = json_encode($this
    ->getSourceData($entity));
  $hash = md5($source_data);
  $metadata = LingotekConfigMetadata::loadByConfigName($entity
    ->getEntityTypeId() . '.' . $entity
    ->id());
  $old_hash = $metadata
    ->getHash();
  if (!$old_hash || strcmp($hash, $old_hash)) {
    $metadata
      ->setHash($hash)
      ->save();
    return TRUE;
  }
  return FALSE;
}