private function MigrateExecutable::importRow in Migrate Manifest 8.2
Same name and namespace in other branches
- 8 src/MigrateExecutable.php \Drupal\migrate_manifest\MigrateExecutable::importRow()
- 3.x src/MigrateExecutable.php \Drupal\migrate_manifest\MigrateExecutable::importRow()
Helper method that imports a single row.
Parameters
\Drupal\migrate\Row $row:
\Drupal\migrate\Plugin\MigrateDestinationInterface $destination:
1 call to MigrateExecutable::importRow()
- MigrateExecutable::import in src/
MigrateExecutable.php - Performs an import operation - migrate items from source to destination.
File
- src/
MigrateExecutable.php, line 93
Class
Namespace
Drupal\migrate_manifestCode
private function importRow(Row $row, MigrateDestinationInterface $destination) {
$id_map = $this->migration
->getIdMap();
// Hide values in internal property so saveMessages can use them.
$this->sourceIdValues = $row
->getSourceIdValues();
try {
$this
->processRow($row);
$this
->getEventDispatcher()
->dispatch(MigrateEvents::PRE_ROW_SAVE, new MigratePreRowSaveEvent($this->migration, $this->message, $row));
$destination_ids = $id_map
->lookupDestinationIds($this->sourceIdValues);
$destination_id_values = $destination_ids ? reset($destination_ids) : [];
$destination_id_values = $destination
->import($row, $destination_id_values);
$this
->getEventDispatcher()
->dispatch(MigrateEvents::POST_ROW_SAVE, new MigratePostRowSaveEvent($this->migration, $this->message, $row, $destination_id_values));
if ($destination_id_values) {
// We do not save an idMap entry for config.
if ($destination_id_values !== TRUE) {
$id_map
->saveIdMapping($row, $destination_id_values, $this->sourceRowStatus, $destination
->rollbackAction());
}
}
else {
$id_map
->saveIdMapping($row, [], MigrateIdMapInterface::STATUS_FAILED);
if (!$id_map
->messageCount()) {
$message = $this
->t('New object was not saved, no error provided');
$this
->saveMessage($message);
$this->message
->display($message);
}
}
} catch (MigrateException $e) {
$id_map
->saveIdMapping($row, [], $e
->getStatus());
$this
->saveMessage($e
->getMessage(), $e
->getLevel());
} catch (MigrateSkipRowException $e) {
if ($e
->getSaveToMap()) {
$id_map
->saveIdMapping($row, [], MigrateIdMapInterface::STATUS_IGNORED);
}
if ($message = trim($e
->getMessage())) {
$this
->saveMessage($message, MigrationInterface::MESSAGE_INFORMATIONAL);
}
} catch (\Exception $e) {
$id_map
->saveIdMapping($row, [], MigrateIdMapInterface::STATUS_FAILED);
$this
->handleException($e);
}
$this->sourceRowStatus = MigrateIdMapInterface::STATUS_IMPORTED;
}