You are here

protected function MediaDevelGenerate::getLangcode in Media entity 8

Determine language based on $results.

Parameters

array $results: The input values from the settings form.

1 call to MediaDevelGenerate::getLangcode()
MediaDevelGenerate::createMediaItem in src/Plugin/DevelGenerate/MediaDevelGenerate.php
Create one media item. Used by both batch and non-batch code branches.

File

src/Plugin/DevelGenerate/MediaDevelGenerate.php, line 447

Class

MediaDevelGenerate
Provides a MediaDevelGenerate plugin.

Namespace

Drupal\media_entity\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;
}