protected function MediaDevelGenerate::getLangcode in Devel 8.3
Same name and namespace in other branches
- 4.x devel_generate/src/Plugin/DevelGenerate/MediaDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\MediaDevelGenerate::getLangcode()
Determine language based on $results.
Parameters
array $results: The input values from the settings form.
Return value
string The language code.
Overrides DevelGenerateBase::getLangcode
1 call to MediaDevelGenerate::getLangcode()
- MediaDevelGenerate::createMediaItem in devel_generate/
src/ Plugin/ DevelGenerate/ MediaDevelGenerate.php - Create one media item. Used by both batch and non-batch code branches.
File
- devel_generate/
src/ Plugin/ DevelGenerate/ MediaDevelGenerate.php, line 527
Class
- MediaDevelGenerate
- Provides a plugin that generates media entities.
Namespace
Drupal\devel_generate\Plugin\DevelGenerateCode
protected function getLangcode(array $results) {
if (isset($results['add_language'])) {
$langcodes = $results['add_language'];
$langcode = $langcodes[array_rand($langcodes)];
}
else {
$langcode = $this->languageManager
->getDefaultLanguage()
->getId();
}
return $langcode;
}