You are here

public function Migrator::migrateAll in Lightning Workflow 8.2

Same name and namespace in other branches
  1. 8.3 modules/lightning_scheduler/src/Migrator.php \Drupal\lightning_scheduler\Migrator::migrateAll()

Migrates all entities of a specific type.

Parameters

string $entity_type_id: The entity type ID to migrate.

callable $callback: (optional) A callback to invoke after each item is migrated. It receives the entity type ID, the number of items migrated so far, the item itself (which will be an \stdClass object), and the migrator service.

Return value

int The number of items that were migrated.

File

modules/lightning_scheduler/src/Migrator.php, line 169

Class

Migrator
This class is final because the migration is not an API and should not be extended or re-used.

Namespace

Drupal\lightning_scheduler

Code

public function migrateAll($entity_type_id, callable $callback = NULL) {
  $items = $this
    ->query($entity_type_id)
    ->execute();
  $count = 0;
  foreach ($items as $item) {
    $this
      ->migrate($entity_type_id, $item);
    if ($callback) {
      $callback($entity_type_id, ++$count, $item, $this);
    }
  }
  $this
    ->completeMigration($entity_type_id);
  return $count;
}