diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php index 9dd69d7..b2cea6f 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php @@ -123,6 +123,13 @@ class Term extends EntityNG implements TermInterface { public $parent; /** + * The Unix timestamp when the term was most recently saved. + * + * @var \Drupal\Core\Entity\Field\FieldInterface + */ + public $changed; + + /** * Implements Drupal\Core\Entity\EntityInterface::id(). */ public function id() { @@ -176,6 +183,14 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont /** * {@inheritdoc} */ + public function preSave(EntityStorageControllerInterface $storage_controller) { + // Before saving the term, set changed time. + $this->changed->value = REQUEST_TIME; + } + + /** + * {@inheritdoc} + */ public function postSave(EntityStorageControllerInterface $storage_controller, $update = TRUE) { // Only change the parents if a value is set, keep the existing values if // not. @@ -185,4 +200,11 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $ } } + /** + * {@inheritdoc} + */ + public function getChangedTime() { + return $this->changed->value; + } + } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermInterface.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermInterface.php index f9bb432..fa4b4ca 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermInterface.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermInterface.php @@ -14,4 +14,12 @@ */ interface TermInterface extends ContentEntityInterface { + /** + * Returns the term modification timestamp. + * + * @return int + * Term modification timestamp. + */ + public function getChangedTime(); + } diff --git a/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install index 4d4c952..c214974 100644 --- a/core/modules/taxonomy/taxonomy.install +++ b/core/modules/taxonomy/taxonomy.install @@ -78,6 +78,12 @@ function taxonomy_schema() { 'default' => 0, 'description' => 'The weight of this term in relation to other terms.', ), + 'changed' => array( + 'description' => 'The Unix timestamp when the term was most recently saved.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), ), 'primary key' => array('tid'), 'unique keys' => array(