class UserLangcode
Same name in this branch
- main core/modules/user/src/Plugin/migrate/process/UserLangcode.php \Drupal\user\Plugin\migrate\process\UserLangcode
Same name and namespace in other branches
- 11.x core/modules/user/src/Plugin/migrate/process/UserLangcode.php \Drupal\user\Plugin\migrate\process\UserLangcode
- 10 core/modules/user/src/Plugin/migrate/process/UserLangcode.php \Drupal\user\Plugin\migrate\process\UserLangcode
- 9 core/modules/user/src/Plugin/migrate/process/UserLangcode.php \Drupal\user\Plugin\migrate\process\UserLangcode
- 8.9.x core/modules/user/src/Plugin/migrate/process/UserLangcode.php \Drupal\user\Plugin\migrate\process\UserLangcode
- 11.x core/modules/migrate/src/Plugin/migrate/process/UserLangcode.php \Drupal\migrate\Plugin\migrate\process\UserLangcode
Provides a process plugin for the user langcode.
Attributes
#[MigrateProcess('user_langcode')]
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\DependencyInjection\AutowiredInstanceTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\migrate\ProcessPluginBase implements \Drupal\migrate\Plugin\MigrateProcessInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\migrate\Plugin\migrate\process\UserLangcode implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface extends \Drupal\migrate\ProcessPluginBase
- class \Drupal\migrate\ProcessPluginBase implements \Drupal\migrate\Plugin\MigrateProcessInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\DependencyInjection\AutowiredInstanceTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of UserLangcode
File
-
core/
modules/ migrate/ src/ Plugin/ migrate/ process/ UserLangcode.php, line 16
Namespace
Drupal\migrate\Plugin\migrate\processView source
class UserLangcode extends ProcessPluginBase implements ContainerFactoryPluginInterface {
public function __construct(array $configuration, $plugin_id, $plugin_definition, #[Autowire(service: 'language_manager')] protected LanguageManager $languageManager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$this->configuration += [
'fallback_to_site_default' => TRUE,
];
// If the user's language is empty, then default to English and set the
// user's preferred_langcode and preferred_admin_langcode to the default
// language.
if (empty($value)) {
return $this->configuration['fallback_to_site_default'] ? $this->languageManager
->getDefaultLanguage()
->getId() : 'en';
}
elseif ($this->languageManager
->getLanguage($value) === NULL) {
return $this->languageManager
->getDefaultLanguage()
->getId();
}
// If the langcode is a valid one, then just return it.
return $value;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.