diff -u b/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php --- b/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -271,7 +271,7 @@ if ($destination_id_values !== TRUE) { $id_map->saveIdMapping($row, $destination_id_values, $this->sourceRowStatus, $this->rollbackAction); } - $this->counters->increment('successes'); + $this->counters->incrementSuccesses(); } else { $id_map->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_FAILED, $this->rollbackAction); @@ -292,7 +292,7 @@ $this->handleException($e); } } - $this->counters->increment('processed'); + $this->counters->incrementProcessed(); if ($high_water_property = $this->migration->get('highWaterProperty')) { $this->migration->saveHighWater($row->getSourceProperty($high_water_property['name'])); } diff -u b/core/modules/migrate/src/MigrationCounters.php b/core/modules/migrate/src/MigrationCounters.php --- b/core/modules/migrate/src/MigrationCounters.php +++ b/core/modules/migrate/src/MigrationCounters.php @@ -52,2 +52,44 @@ + /** + * {@inheritdoc} + */ + public function getSuccesses() { + return $this->get('successes'); + } + + /** + * {@inheritdoc} + */ + public function incrementSuccesses() { + $this->increment('successes'); + } + + /** + * {@inheritdoc} + */ + public function resetSuccesses() { + $this->reset('successes'); + } + + /** + * {@inheritdoc} + */ + public function getProcessed() { + return $this->get('processed'); + } + + /** + * {@inheritdoc} + */ + public function incrementProcessed() { + $this->increment('processed'); + } + + /** + * {@inheritdoc} + */ + public function resetProcessed() { + $this->reset('processed'); + } + } diff -u b/core/modules/migrate/src/MigrationCountersInterface.php b/core/modules/migrate/src/MigrationCountersInterface.php --- b/core/modules/migrate/src/MigrationCountersInterface.php +++ b/core/modules/migrate/src/MigrationCountersInterface.php @@ -19,7 +19,7 @@ * Name of the counter (e.g., "successes"). * * @return int - * The total number of successes, or 0 if no counter by this name exists. + * The total for this counter, or 0 if no counter by this name exists. */ public function get($counter_name); @@ -42,2 +42,37 @@ -} + /** + * Returns the current success counter value. + * + * @return int + * The total number of successes, or 0 if no counter by this name exists. + */ + public function getSuccesses(); + + /** + * Increments the successes counter. + */ + public function incrementSuccesses(); + + /** + * Resets the successes counter to 0. + */ + public function resetSuccesses(); + /** + * Returns the current processed counter value. + * + * @return int + * The total number processed, or 0 if no counter by this name exists. + */ + public function getProcessed(); + + /** + * Increments the processed counter. + */ + public function incrementProcessed(); + + /** + * Resets the processed counter to 0. + */ + public function resetProcessed(); + +} diff -u b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php --- b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php @@ -122,8 +122,14 @@ $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); $counters = $this->executable->getCounters(); - $this->assertSame(1, $counters->get('successes')); - $this->assertSame(1, $counters->get('processed')); + $this->assertSame(1, $counters->getSuccesses()); + $this->assertSame(1, $counters->getProcessed()); + + $counters->resetSuccesses(); + $this->assertSame(0, $counters->getSuccesses()); + + $counters->resetProcessed(); + $this->assertSame(0, $counters->getProcessed()); } /**