class MigrateExecutable extends MigrateExecutable (View source)

Properties

protected OutputInterface $output

The Symfony console output.

protected array $saveCounters

Counters of map statuses.

protected int $deleteCounter

Counter of map deletions.

protected string|null $limit

Maximum number of items to process in this migration.

protected string|null $feedback

Frequency (in items) at which progress messages should be emitted.

protected bool $showTimestamp

Show timestamp in progress message.

protected bool $showTotal

Show internal counter in progress message.

protected array $idlist

List of specific source IDs to import.

protected array $allSourceIdValues

List of all source IDs that are found in source during this migration.

protected int $counter

Count of number of items processed so far in this migration.

protected bool $preExistingItem

Whether the destination item exists before saving.

protected callable[] $listeners

List of event listeners we have registered.

protected bool $deleteMissingSourceRows

Whether to delete rows missing from source after an import.

protected MigrateIdMapFilter|null $idMap

Static cached ID map.

protected bool $exposeProgressBar

If the execution exposes a progress bar.

protected ProgressBar|null $progressBar

The Symfony progress bar.

Methods

__construct(MigrationInterface $migration, MigrateMessageInterface $message, OutputInterface $output, array $options = [])

Constructs a new migrate executable instance.

void
onMapSave(MigrateMapSaveEvent $event)

Counts up any map save events.

void
onMapDelete(MigrateMapDeleteEvent $event)

Counts up any rollback events.

void
onPreImport(MigrateImportEvent $event)

Reacts when the import is about to start.

void
handleMissingSourceRows(MigrationInterface $migration)

Handles missing source rows after import.

void
onMissingSourceRows(MigrateMissingSourceRowsEvent $event)

Reacts on detecting a list of missing source rows after an import.

void
onPostImport(MigrateImportEvent $event)

Reacts to migration completion.

void
importFeedbackMessage(bool $done = true)

Emits information on the import progress.

void
onPreRollback(MigrateRollbackEvent $event)

Reacts when the rollback is about to starts.

void
onPostRollback(MigrateRollbackEvent $event)

Reacts to rollback completion.

void
rollbackFeedbackMessage(bool $done = true)

Emits information on the rollback execution progress.

void
onPreRowSave(MigratePreRowSaveEvent $event)

Reacts to an item about to be imported.

void
onPostRowSave(MigratePostRowSaveEvent $event)

Reacts aftre a row has been deleted.

void
onPostRowDelete(MigrateRowDeleteEvent $event)

Reacts to item rollback.

void
onPrepareRow(MigratePrepareRowEvent $event)

Reacts to a new row being prepared.

getIdMap()

{@inheritdoc}

int
getCreatedCount()

Returns the number of items created.

int
getUpdatedCount()

Returns the number of items updated.

int
getIgnoredCount()

Returns the number of items ignored.

int
getFailedCount()

Returns the number of items that failed.

int
getProcessedCount()

Returns the total number of items processed.

int
getRollbackCount()

Returns the number of items rolled back.

void
resetCounters()

Resets all the per-status counters to 0.

void
initProgressBar(MigrationInterface $migration)

Initializes the command progress bar if possible.

void
updateProgressBar()

Advances the progress bar.

void
progressFinish()

Removes the progress bar after operation is finished.

void
unregisterListeners()

Unregisters all event listeners.

Details

__construct(MigrationInterface $migration, MigrateMessageInterface $message, OutputInterface $output, array $options = [])

Constructs a new migrate executable instance.

Parameters

MigrationInterface $migration
MigrateMessageInterface $message
OutputInterface $output
array $options

void onMapSave(MigrateMapSaveEvent $event)

Counts up any map save events.

Parameters

MigrateMapSaveEvent $event

The map event.

Return Value

void

void onMapDelete(MigrateMapDeleteEvent $event)

Counts up any rollback events.

Parameters

MigrateMapDeleteEvent $event

The map event.

Return Value

void

void onPreImport(MigrateImportEvent $event)

Reacts when the import is about to start.

Parameters

MigrateImportEvent $event

The import event.

Return Value

void

protected void handleMissingSourceRows(MigrationInterface $migration)

Handles missing source rows after import.

Detect if, before importing, the destination contains rows that are no more available in the source. If we can build such a list, we dispatch the \Drush\Drupal\Migrate\MigrateMissingSourceRowsEvent event, allowing subscribers to perform specific actions on detected destination objects. We also provide a default listener to this event that rolls-back the items, if the --delete option has been passed.

Custom subscribers, provided by third-party code, may also subscribe, with a higher priority, to the same event, and perform different tasks, such as unpublishing the destination entity and then stopping the event propagation, thus avoiding the destination object rollback, even when the--delete option has been passed.

Parameters

MigrationInterface $migration

Return Value

void

See also

MigrateExecutable::onMissingSourceRows

void onMissingSourceRows(MigrateMissingSourceRowsEvent $event)

Reacts on detecting a list of missing source rows after an import.

Note that third-party code may subscribe to the same event, with a higher priority, and perform different tasks, such as unpublishing the destination entity and then stopping the event propagation, thus avoiding the destination object deletion, even the --delete option was passed.

Parameters

MigrateMissingSourceRowsEvent $event

The event object.

Return Value

void

void onPostImport(MigrateImportEvent $event)

Reacts to migration completion.

Parameters

MigrateImportEvent $event

The map event.

Return Value

void

protected void importFeedbackMessage(bool $done = true)

Emits information on the import progress.

Parameters

bool $done

Return Value

void

void onPreRollback(MigrateRollbackEvent $event)

Reacts when the rollback is about to starts.

Parameters

MigrateRollbackEvent $event

The map event.

Return Value

void

void onPostRollback(MigrateRollbackEvent $event)

Reacts to rollback completion.

Parameters

MigrateRollbackEvent $event

The map event.

Return Value

void

protected void rollbackFeedbackMessage(bool $done = true)

Emits information on the rollback execution progress.

Parameters

bool $done

Return Value

void

void onPreRowSave(MigratePreRowSaveEvent $event)

Reacts to an item about to be imported.

Parameters

MigratePreRowSaveEvent $event

The pre-save event.

Return Value

void

void onPostRowSave(MigratePostRowSaveEvent $event)

Reacts aftre a row has been deleted.

Parameters

MigratePostRowSaveEvent $event

The event.

Return Value

void

void onPostRowDelete(MigrateRowDeleteEvent $event)

Reacts to item rollback.

Parameters

MigrateRowDeleteEvent $event

The post-save event.

Return Value

void

void onPrepareRow(MigratePrepareRowEvent $event)

Reacts to a new row being prepared.

Parameters

MigratePrepareRowEvent $event

The prepare-row event.

Return Value

void

Exceptions

MigrateSkipRowException

protected MigrateIdMapFilter getIdMap()

{@inheritdoc}

Return Value

MigrateIdMapFilter

int getCreatedCount()

Returns the number of items created.

Return Value

int

int getUpdatedCount()

Returns the number of items updated.

Return Value

int

int getIgnoredCount()

Returns the number of items ignored.

Return Value

int

int getFailedCount()

Returns the number of items that failed.

Return Value

int

int getProcessedCount()

Returns the total number of items processed.

Note that STATUS_NEEDS_UPDATE is not counted, since this is typically set on stubs created as side effects, not on the primary item being imported.

Return Value

int

int getRollbackCount()

Returns the number of items rolled back.

Return Value

int

protected void resetCounters()

Resets all the per-status counters to 0.

Return Value

void

protected void initProgressBar(MigrationInterface $migration)

Initializes the command progress bar if possible.

Parameters

MigrationInterface $migration

The migration.

Return Value

void

void updateProgressBar()

Advances the progress bar.

Return Value

void

void progressFinish()

Removes the progress bar after operation is finished.

Return Value

void

void unregisterListeners()

Unregisters all event listeners.

Return Value

void