/** * {@inheritdoc} */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { if (!isset($this->configuration['fallback_to_site_default'])) { $this->configuration['fallback_to_site_default'] = TRUE; } // If the user's language is empty, it means the locale module was not // installed, so the user's langcode should be English and the user's // preferred_langcode and preferred_admin_langcode should fallback to the // default language. if (empty($value)) { if ($this->configuration['fallback_to_site_default']) { return $this->languageManager->getDefaultLanguage()->getId(); } else { return 'en'; } } // If the user's language does not exists, use the default language. elseif ($this->languageManager->getLanguage($value) === NULL) { return $this->languageManager->getDefaultLanguage()->getId(); } // If the langcode is a valid one, just return it. return $value; }