Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DefaultLangcode.php

function DefaultLangcode::import

Overrides Config::import

File

core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php, line 20

Class

DefaultLangcode
Provides a destination plugin for the default langcode config.

Namespace

Drupal\language\Plugin\migrate\destination

Code

public function import(Row $row, array $old_destination_id_values = []) {
    $destination = $row->getDestination();
    $langcode = $destination['default_langcode'];
    // Check if the language exists.
    if (ConfigurableLanguage::load($langcode) === NULL) {
        throw new MigrateException("The language '{$langcode}' does not exist on this site.");
    }
    $this->config
        ->set('default_langcode', $destination['default_langcode']);
    $this->config
        ->save();
    return [
        $this->config
            ->getName(),
    ];
}
RSS feed
Powered by Drupal