You are here

protected function ContentDevelGenerate::getLangcode in Devel 8.2

Same name and namespace in other branches
  1. 8 devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate::getLangcode()

Determine language based on $results.

1 call to ContentDevelGenerate::getLangcode()
ContentDevelGenerate::develGenerateContentAddNode in devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php
Create one node. Used by both batch and non-batch code branches.

File

devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php, line 534

Class

ContentDevelGenerate
Provides a ContentDevelGenerate plugin.

Namespace

Drupal\devel_generate\Plugin\DevelGenerate

Code

protected function getLangcode($results) {
  if (isset($results['add_language'])) {
    $langcodes = $results['add_language'];
    $langcode = $langcodes[array_rand($langcodes)];
  }
  else {
    $langcode = $this->languageManager
      ->getDefaultLanguage()
      ->getId();
  }
  return $langcode;
}