You are here

public function State::import in Acquia Connector 3.x

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/State.php, line 111

Class

State
The destination plugin for importing data into the state.

Namespace

Drupal\acquia_connector\Plugin\migrate\destination

Code

public function import(Row $row, array $old_destination_id_values = []) {
  $ids = [];
  foreach ($row
    ->getDestination() as $key => $value) {
    $key = $this->configuration['state_prefix'] . $key;
    $this->state
      ->set($key, $value);
    $ids[] = $key;
  }

  // Contrary to configuration entities, states can not be nested,
  // so every state must be stored separately from others.
  // To be able to migrate several states in one migrate source row,
  // combine their names and send as one ID.
  return [
    implode(',', $ids),
  ];
}