function Config::import

Same name in other branches
  1. 9 core/modules/migrate/src/Plugin/migrate/destination/Config.php \Drupal\migrate\Plugin\migrate\destination\Config::import()
  2. 8.9.x core/modules/migrate/src/Plugin/migrate/destination/Config.php \Drupal\migrate\Plugin\migrate\destination\Config::import()
  3. 11.x core/modules/migrate/src/Plugin/migrate/destination/Config.php \Drupal\migrate\Plugin\migrate\destination\Config::import()

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 147

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);
        }
    }
    $name = $this->config
        ->getName();
    // Ensure that translatable config has `langcode` specified.
    // @see \Drupal\Core\Config\Plugin\Validation\Constraint\LangcodeRequiredIfTranslatableValuesConstraint
    if ($this->typedConfigManager
        ->hasConfigSchema($name) && $this->typedConfigManager
        ->createFromNameAndData($name, $this->config
        ->getRawData())
        ->hasTranslatableElements() && !$this->config
        ->get('langcode')) {
        $this->config
            ->set('langcode', $this->language_manager
            ->getDefaultLanguage()
            ->getId());
    }
    $this->config
        ->save();
    $ids[] = $this->config
        ->getName();
    if ($this->isTranslationDestination()) {
        $ids[] = $row->getDestinationProperty('langcode');
    }
    return $ids;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.