function LanguageOptions::getPossibleOptions
Overrides OptionsProviderInterface::getPossibleOptions
File
-
src/
TypedData/ Options/ LanguageOptions.php, line 45
Class
- LanguageOptions
- Options provider to list all languages enabled on the site.
Namespace
Drupal\rules\TypedData\OptionsCode
public function getPossibleOptions(AccountInterface $account = NULL) {
$languages = $this->languageManager
->getLanguages(LanguageInterface::STATE_CONFIGURABLE);
$default = $this->languageManager
->getDefaultLanguage()
->getId();
$options = [
LanguageInterface::LANGCODE_NOT_SPECIFIED => $this->t('Not specified'),
];
foreach ($languages as $langcode => $language) {
$options[$langcode] = $language->getName() . ($langcode == $default ? ' - default' : '') . ' (' . $langcode . ')';
}
// Sort the result by value for ease of locating and selecting.
asort($options);
return $options;
}