You are here

public function Update::getChangedTimeAcrossTranslations in Update helper 8

Same name and namespace in other branches
  1. 2.x modules/update_helper_checklist/src/Entity/Update.php \Drupal\update_helper_checklist\Entity\Update::getChangedTimeAcrossTranslations()

Gets the timestamp of the last entity change across all translations.

This method will return the highest timestamp across all translations. To check that no translation is older than in another version of the entity (e.g. to avoid overwriting newer translations with old data), compare each translation to the other version individually.

Return value

int The timestamp of the last entity save operation across all translations.

Overrides EntityChangedInterface::getChangedTimeAcrossTranslations

File

modules/update_helper_checklist/src/Entity/Update.php, line 79

Class

Update
Defines the Contact entity.

Namespace

Drupal\update_helper_checklist\Entity

Code

public function getChangedTimeAcrossTranslations() {
  $changed = $this
    ->getUntranslated()
    ->getChangedTime();
  foreach ($this
    ->getTranslationLanguages(FALSE) as $language) {
    $translation_changed = $this
      ->getTranslation($language
      ->getId())
      ->getChangedTime();
    $changed = max($translation_changed, $changed);
  }
  return $changed;
}