You are here

public function Table::import in Migrate Plus 8.3

Same name and namespace in other branches
  1. 8.5 src/Plugin/migrate/destination/Table.php \Drupal\migrate_plus\Plugin\migrate\destination\Table::import()
  2. 8.4 src/Plugin/migrate/destination/Table.php \Drupal\migrate_plus\Plugin\migrate\destination\Table::import()

Import the row.

Derived classes must implement import(), to construct one new object (pre-populated) using ID mappings in the Migration.

Parameters

\Drupal\migrate\Row $row: The row object.

array $old_destination_id_values: (optional) The old destination IDs. Defaults to an empty array.

Return value

array|bool An indexed array of destination IDs in the same order as defined in the plugin's getIds() method if the plugin wants to save the IDs to the ID map, TRUE to indicate success without saving IDs to the ID map, or FALSE to indicate a failure.

Overrides MigrateDestinationInterface::import

File

src/Plugin/migrate/destination/Table.php, line 98

Class

Table
Provides table destination plugin.

Namespace

Drupal\migrate_plus\Plugin\migrate\destination

Code

public function import(Row $row, array $old_destination_id_values = []) {
  $id = $row
    ->getSourceIdValues();
  if (count($id) != count($this->idFields)) {
    throw new MigrateSkipProcessException('All the id fields are required for a table migration.');
  }
  $values = $row
    ->getDestination();
  if ($this->fields) {
    $values = array_intersect_key($values, $this->fields);
  }
  $status = $this->dbConnection
    ->merge($this->tableName)
    ->key($id)
    ->fields($values)
    ->execute();
  return $status ? $id : NULL;
}