diff -u b/migrate_tools/migrate_tools.drush.inc b/migrate_tools/migrate_tools.drush.inc --- b/migrate_tools/migrate_tools.drush.inc +++ b/migrate_tools/migrate_tools.drush.inc @@ -10,6 +10,7 @@ use Drupal\migrate_tools\MigrateExecutable; use Drupal\migrate_tools\DrushLogMigrateMessage; use Drupal\migrate_tools\MigrateManifest; +use Drupal\Core\Datetime\DateFormatter; /** * Implements hook_drush_command(). @@ -92,6 +93,7 @@ dt('Total'), dt('Imported'), dt('Unprocessed'), + dt('Last imported'), ); } foreach ($migration_list as $migration_id => $migration) { @@ -125,7 +127,18 @@ $table[] = array($migration_id); } else { - $table[] = array($migration_id, $source_rows, $imported, $unprocessed); + $migrate_last_imported_store = \Drupal::keyValue('migrate_last_imported'); + $last_imported = $migrate_last_imported_store->get($migration->id(), FALSE); + if ($last_imported) { + /** @var DateFormatter $date_formatter */ + $date_formatter = \Drupal::service('date.formatter'); + $last_imported = $date_formatter->format($last_imported / 1000, + 'custom', 'Y-m-d H:i:s'); + } + else { + $last_imported = ''; + } + $table[] = array($migration_id, $source_rows, $imported, $unprocessed, $last_imported); } } } diff -u b/migrate_tools/src/MigrateExecutable.php b/migrate_tools/src/MigrateExecutable.php --- b/migrate_tools/src/MigrateExecutable.php +++ b/migrate_tools/src/MigrateExecutable.php @@ -14,6 +14,7 @@ use Drupal\migrate\MigrateEvents; use Drupal\migrate\MigrateMapSaveEvent; use Drupal\migrate\MigrateMapDeleteEvent; +use Drupal\migrate\MigratePostImportEvent; class MigrateExecutable extends MigrateExecutableBase { @@ -46,6 +47,8 @@ array($this, 'onMapSave')); \Drupal::service('event_dispatcher')->addListener(MigrateEvents::MAP_DELETE, array($this, 'onMapDelete')); + \Drupal::service('event_dispatcher')->addListener(MigrateEvents::POST_IMPORT, + array($this, 'onPostImport')); } /** @@ -120,2 +123,13 @@ + /** + * React to migration completion. + * + * @param \Drupal\migrate\MigratePostImportEvent $event + * The map event. + */ + public function onPostImport(MigratePostImportEvent $event) { + $migrate_last_imported_store = \Drupal::keyValue('migrate_last_imported'); + $migrate_last_imported_store->set($event->getMigration()->id(), round(microtime(TRUE) * 1000)); + } + } only in patch2: unchanged: --- a/migrate_tools/src/Controller/MigrationListBuilder.php +++ b/migrate_tools/src/Controller/MigrationListBuilder.php @@ -15,6 +15,7 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Routing\CurrentRouteMatch; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Datetime\DateFormatter; /** * Provides a listing of migration entities in a given group. @@ -68,6 +69,7 @@ class MigrationListBuilder extends ConfigEntityListBuilder implements EntityHand $header['total'] = $this->t('Total'); $header['imported'] = $this->t('Imported'); $header['unprocessed'] = $this->t('Unprocessed'); + $header['last_imported'] = $this->t('Last Imported'); return $header + parent::buildHeader(); } @@ -99,7 +101,17 @@ class MigrationListBuilder extends ConfigEntityListBuilder implements EntityHand else { $row['unprocessed'] = $row['total'] - $map->processedCount(); } - + $migrate_last_imported_store = \Drupal::keyValue('migrate_last_imported'); + $last_imported = $migrate_last_imported_store->get($migration->id(), FALSE); + if ($last_imported) { + /** @var DateFormatter $date_formatter */ + $date_formatter = \Drupal::service('date.formatter'); + $row['last_imported'] = $date_formatter->format($last_imported / 1000, + 'custom', 'Y-m-d H:i:s'); + } + else { + $row['last_imported'] = ''; + } return $row + parent::buildRow($migration); }