You are here

public function LingotekConfigTranslationService::hasEntityChanged in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  2. 8.2 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  3. 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  4. 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  5. 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  6. 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
  7. 3.3.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

\Drupal\Core\Config\ConfigEntityInterface &$entity: The entity being checked

Return value

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

Overrides LingotekConfigTranslationServiceInterface::hasEntityChanged

File

src/LingotekConfigTranslationService.php, line 281

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;
}