File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 */
66
77use Drupal\Core\Database\Query\AlterableInterface;
8- use Drupal\Core\Entity\EntityTypeInterface;
98use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
109use Drupal\Core\Entity\EntityInterface;
10+ use Drupal\Core\Entity\EntityTypeInterface;
1111use Drupal\Core\Form\FormStateInterface;
12- use Drupal\metastore\NodeWrapper\Data;
1312use Drupal\metastore\MetastoreService;
13+ use Drupal\metastore\NodeWrapper\Data;
14+ use Drupal\metastore\Factory\MetastoreEntityItemFactoryInterface;
1415use Drupal\metastore\Service\OrphanNodeProcessor;
1516
1617/**
@@ -27,6 +28,15 @@ function metastore_entity_load(array $entities) {
2728 * Implements hook_entity_presave().
2829 */
2930function metastore_entity_presave(EntityInterface $entity) {
31+ // Check if the entity is a data entity and a new revision is being created.
32+ /** @var MetastoreEntityItemFactoryInterface $storage */
33+ $metastore_service = \Drupal::service('dkan.metastore.metastore_item_factory');
34+ if ($entity->getEntityTypeId() === $metastore_service::getEntityType() && in_array($entity->bundle(), $metastore_service::getBundles()) && $entity->isNewRevision()) {
35+ // Set revision creation time to the current time because programmatically
36+ // saved revisions will reuse the previous revision's timestamp if not
37+ // explicitly set.
38+ $entity->setRevisionCreationTime(\Drupal::time()->getCurrentTime());
39+ }
3040 metastore_data_lifecycle([$entity], "presave");
3141}
3242
You can’t perform that action at this time.
0 commit comments