diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/Validation/Constraint/EntityChangedConstraint.php b/core/modules/entity/lib/Drupal/entity/Plugin/Validation/Constraint/EntityChangedConstraint.php new file mode 100644 index 0000000..5327c70 --- /dev/null +++ b/core/modules/entity/lib/Drupal/entity/Plugin/Validation/Constraint/EntityChangedConstraint.php @@ -0,0 +1,25 @@ +context->getMetadata()->getTypedData()->getParent()->getParent(); + $saved_entity = entity_load_unchanged($entity->type, $entity->id()); + if (!empty($saved_entity) && ($saved_entity instanceof EntityChangedInterface) && ($saved_entity->getChangedTime() > $value)) { + $this->context->addViolation($constraint->message); + } + } + } +} diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php index 99063bb..f69bf1a 100644 --- a/core/modules/node/lib/Drupal/node/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Entity/Node.php @@ -376,7 +376,7 @@ public static function baseFieldDefinitions($entity_type) { 'description' => t('The time that the node was last edited.'), 'type' => 'integer_field', 'property_constraints' => array( - 'value' => array('NodeChanged' => array()), + 'value' => array('EntityChanged' => array()), ), ); $properties['comment'] = array( diff --git a/core/modules/node/lib/Drupal/node/Plugin/Validation/Constraint/NodeChangedConstraint.php b/core/modules/node/lib/Drupal/node/Plugin/Validation/Constraint/NodeChangedConstraint.php deleted file mode 100644 index 1ca461f..0000000 --- a/core/modules/node/lib/Drupal/node/Plugin/Validation/Constraint/NodeChangedConstraint.php +++ /dev/null @@ -1,25 +0,0 @@ -context->getMetadata()->getTypedData()->getParent()->getParent(); - $id = $node->id(); - $language = $node->language(); - if ($id && (node_last_changed($id, $language->id) > $value)) { - $this->context->addViolation($constraint->message); - } - } - } -} diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php index da83581..4fb9b13 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php @@ -253,6 +253,9 @@ public static function baseFieldDefinitions($entity_type) { 'label' => t('Changed'), 'description' => t('The time that the term was last edited.'), 'type' => 'integer_field', + 'property_constraints' => array( + 'value' => array('EntityChanged' => array()), + ), ); return $properties; }