Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / devel / devel_generate / src / Plugin / DevelGenerate / TermDevelGenerate.php
index f7aa39b8073dda83f18f0972f68d6c3467124c67..61e6dd4110ba9df18212949b82487debd1fc3fe2 100644 (file)
@@ -210,15 +210,6 @@ class TermDevelGenerate extends DevelGenerateBase implements ContainerFactoryPlu
 
       $max++;
 
-      if (function_exists('drush_log')) {
-        $feedback = drush_get_option('feedback', 1000);
-        if ($i % $feedback == 0) {
-          $now = time();
-          drush_log(dt('Completed @feedback terms (@rate terms/min)', array('@feedback' => $feedback, '@rate' => $feedback * 60 / ($now - $start))), 'ok');
-          $start = $now;
-        }
-      }
-
       // Limit memory usage. Only report first 20 created terms.
       if ($i < 20) {
         $terms[] = $term->label();
@@ -233,7 +224,7 @@ class TermDevelGenerate extends DevelGenerateBase implements ContainerFactoryPlu
   /**
    * {@inheritdoc}
    */
-  public function validateDrushParams($args) {
+  public function validateDrushParams($args, $options = []) {
     $vocabulary_name = array_shift($args);
     $number = array_shift($args);
 
@@ -242,21 +233,21 @@ class TermDevelGenerate extends DevelGenerateBase implements ContainerFactoryPlu
     }
 
     if (!$vocabulary_name) {
-      return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Please provide a vocabulary machine name.'));
+      throw new \Exception(dt('Please provide a vocabulary machine name.'));
     }
 
     if (!$this->isNumber($number)) {
-      return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of terms: @num', array('@num' => $number)));
+      throw new \Exception(dt('Invalid number of terms: @num', array('@num' => $number)));
     }
 
     // Try to convert machine name to a vocabulary id.
     if (!$vocabulary = $this->vocabularyStorage->load($vocabulary_name)) {
-      return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid vocabulary name: @name', array('@name' => $vocabulary_name)));
+      throw new \Exception(dt('Invalid vocabulary name: @name', array('@name' => $vocabulary_name)));
     }
 
     $values = [
       'num' => $number,
-      'kill' => drush_get_option('kill'),
+      'kill' => $this->isDrush8() ? drush_get_option('kill') : $options['kill'],
       'title_length' => 12,
       'vids' => [$vocabulary->id()],
     ];