public function LingotekContentTranslationService::hasEntityChanged in Lingotek Translation 3.2.x
Same name and namespace in other branches
- 8 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::hasEntityChanged()
- 8.2 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::hasEntityChanged()
- 4.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::hasEntityChanged()
- 3.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::hasEntityChanged()
- 3.1.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::hasEntityChanged()
- 3.3.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::hasEntityChanged()
- 3.4.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::hasEntityChanged()
- 3.5.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::hasEntityChanged()
- 3.6.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::hasEntityChanged()
- 3.7.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::hasEntityChanged()
- 3.8.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::hasEntityChanged()
Checks if the source entity data has changed from last time we uploaded it.
Parameters
\Drupal\Core\Entity\ContentEntityInterface &$entity: The entity being checked
Return value
bool TRUE if the entity has changed, false if not.
Overrides LingotekContentTranslationServiceInterface::hasEntityChanged
File
- src/
LingotekContentTranslationService.php, line 695
Class
- LingotekContentTranslationService
- Service for managing Lingotek content translations.
Namespace
Drupal\lingotekCode
public function hasEntityChanged(ContentEntityInterface &$entity) {
if (isset($entity->original)) {
if ($entity
->getRevisionId() !== $entity->original
->getRevisionId()) {
return TRUE;
}
$source_data = $this
->getSourceData($entity);
if (isset($source_data['_lingotek_metadata'])) {
unset($source_data['_lingotek_metadata']['_entity_revision']);
}
$source_data = json_encode($source_data);
$hash = md5($source_data);
$old_source_data = $this
->getSourceData($entity->original);
if (isset($old_source_data['_lingotek_metadata'])) {
unset($old_source_data['_lingotek_metadata']['_entity_revision']);
}
$old_source_data = json_encode($old_source_data);
$old_hash = md5($old_source_data);
return (bool) strcmp($hash, $old_hash);
}
else {
return TRUE;
}
}