3 namespace Drupal\Core\Entity;
6 * Provides a trait for accessing changed time.
8 trait EntityChangedTrait {
11 * Returns the timestamp of the last entity change across all translations.
14 * The timestamp of the last entity save operation across all
17 public function getChangedTimeAcrossTranslations() {
18 $changed = $this->getUntranslated()->getChangedTime();
19 foreach ($this->getTranslationLanguages(FALSE) as $language) {
20 $translation_changed = $this->getTranslation($language->getId())->getChangedTime();
21 $changed = max($translation_changed, $changed);
27 * Gets the timestamp of the last entity change for the current translation.
30 * The timestamp of the last entity save operation.
32 public function getChangedTime() {
33 return $this->get('changed')->value;
37 * Sets the timestamp of the last entity change for the current translation.
39 * @param int $timestamp
40 * The timestamp of the last entity save operation.
44 public function setChangedTime($timestamp) {
45 $this->set('changed', $timestamp);