public function LingotekConfigTranslationService::hasEntityChanged in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
- 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
- 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
- 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
- 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
- 3.3.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
- 3.4.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
- 3.5.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
- 3.6.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
- 3.7.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::hasEntityChanged()
- 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\lingotekCode
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;
}