public static function LanguageItem::getLanguageConfigurationValues in Custom Language field 8
Get language configuration value.
Parameters
string $code: Code.
Return value
string Value.
1 call to LanguageItem::getLanguageConfigurationValues()
- LanguageSelectWidget::massageFormValues in src/
Plugin/ Field/ FieldWidget/ LanguageSelectWidget.php - @inheritdoc
File
- src/
Plugin/ Field/ FieldType/ LanguageItem.php, line 107
Class
- LanguageItem
- Plugin implementation of the 'language' field type.
Namespace
Drupal\languagefield\Plugin\Field\FieldTypeCode
public static function getLanguageConfigurationValues($code) {
switch ($code) {
case LanguageInterface::LANGCODE_SITE_DEFAULT:
$language = \Drupal::languageManager()
->getDefaultLanguage();
$value = $language
->getId();
break;
case LanguageInterface::LANGCODE_NOT_SPECIFIED:
$value = LanguageInterface::LANGCODE_NOT_SPECIFIED;
break;
case 'current_interface':
$language = \Drupal::languageManager()
->getCurrentLanguage();
$value = $language
->getId();
break;
case 'authors_default':
$user = \Drupal::currentUser();
$language_code = $user
->getPreferredLangcode();
$language = !empty($language_code) ? \Drupal::languageManager()
->getLanguage($language_code) : \Drupal::languageManager()
->getCurrentLanguage();
$value = $language
->getId();
break;
default:
$value = $code;
}
return $value;
}