You are here

public function MediaDevelGenerate::validateDrushParams in Media entity 8

File

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

Class

MediaDevelGenerate
Provides a MediaDevelGenerate plugin.

Namespace

Drupal\media_entity\Plugin\DevelGenerate

Code

public function validateDrushParams($args) {
  $add_language = drush_get_option('languages');
  if (!empty($add_language)) {
    $add_language = explode(',', str_replace(' ', '', $add_language));

    // Intersect with the enabled languages to make sure the language args
    // passed are actually enabled.
    $values['values']['add_language'] = array_intersect($add_language, array_keys($this->languageManager
      ->getLanguages(LanguageInterface::STATE_ALL)));
  }
  $values['kill'] = drush_get_option('kill');
  $values['name_length'] = drush_get_option('name_length', 6);
  $values['num'] = array_shift($args);
  $selected_bundles = _convert_csv_to_array(drush_get_option('bundles', []));
  if (empty($selected_bundles)) {
    return drush_set_error('DEVEL_GENERATE_NO_MEDIA_BUNDLES', dt('No media bundles available'));
  }
  $values['media_bundles'] = array_combine($selected_bundles, $selected_bundles);
  return $values;
}