You are here

public function Config::import in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/src/Plugin/migrate/destination/Config.php \Drupal\migrate\Plugin\migrate\destination\Config::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

1 method overrides Config::import()
DefaultLangcode::import in core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php
Import the row.

File

core/modules/migrate/src/Plugin/migrate/destination/Config.php, line 132

Class

Config
Provides Configuration Management destination plugin.

Namespace

Drupal\migrate\Plugin\migrate\destination

Code

public function import(Row $row, array $old_destination_id_values = []) {
  if ($this
    ->isTranslationDestination()) {
    $this->config = $this->language_manager
      ->getLanguageConfigOverride($row
      ->getDestinationProperty('langcode'), $this->config
      ->getName());
  }
  foreach ($row
    ->getRawDestination() as $key => $value) {
    if (isset($value) || !empty($this->configuration['store null'])) {
      $this->config
        ->set(str_replace(Row::PROPERTY_SEPARATOR, '.', $key), $value);
    }
  }
  $this->config
    ->save();
  $ids[] = $this->config
    ->getName();
  if ($this
    ->isTranslationDestination()) {
    $ids[] = $row
      ->getDestinationProperty('langcode');
  }
  return $ids;
}