Same filename and directory in other branches
- 8.9.x core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php
- 9 core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php
Namespace
Drupal\language\Plugin\migrate\destination
File
core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php
View source
<?php
namespace Drupal\language\Plugin\migrate\destination;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\migrate\Attribute\MigrateDestination;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\migrate\destination\Config;
use Drupal\migrate\Row;
class DefaultLangcode extends Config {
public function import(Row $row, array $old_destination_id_values = []) {
$destination = $row
->getDestination();
$langcode = $destination['default_langcode'];
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(),
];
}
}
Classes