Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Create / VocabulariesCommand.php
index 4af2244440425953cf34fdcdd46dedbec6cbe39e..5d45265f5a296b7b0c1627ded91c8044bec5d164 100644 (file)
@@ -7,13 +7,11 @@
 
 namespace Drupal\Console\Command\Create;
 
-use Drupal\Console\Core\Command\Shared\CommandTrait;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Console\Utils\Create\VocabularyData;
-use Drupal\Console\Core\Style\DrupalStyle;
 
 /**
  * Class VocabulariesCommand
@@ -22,8 +20,6 @@ use Drupal\Console\Core\Style\DrupalStyle;
  */
 class VocabulariesCommand extends Command
 {
-    use CommandTrait;
-
     /**
      * @var VocabularyData
      */
@@ -59,7 +55,7 @@ class VocabulariesCommand extends Command
                 null,
                 InputOption::VALUE_OPTIONAL,
                 $this->trans('commands.create.vocabularies.options.name-words')
-            );
+            )->setAliases(['crv']);
     }
 
     /**
@@ -67,11 +63,9 @@ class VocabulariesCommand extends Command
      */
     protected function interact(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $limit = $input->getOption('limit');
         if (!$limit) {
-            $limit = $io->ask(
+            $limit = $this->getIo()->ask(
                 $this->trans('commands.create.vocabularies.questions.limit'),
                 25
             );
@@ -80,7 +74,7 @@ class VocabulariesCommand extends Command
 
         $nameWords = $input->getOption('name-words');
         if (!$nameWords) {
-            $nameWords = $io->ask(
+            $nameWords = $this->getIo()->ask(
                 $this->trans('commands.create.vocabularies.questions.name-words'),
                 5
             );
@@ -94,12 +88,10 @@ class VocabulariesCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $limit = $input->getOption('limit')?:25;
         $nameWords = $input->getOption('name-words')?:5;
 
-        $vocabularies = $this->vocabularyData->create(
+        $result = $this->vocabularyData->create(
             $limit,
             $nameWords
         );
@@ -109,24 +101,28 @@ class VocabulariesCommand extends Command
           $this->trans('commands.create.vocabularies.messages.name'),
         ];
 
-        if (isset($vocabularies['success'])) {
-            $io->table($tableHeader, $vocabularies['success']);
+        if (isset($result['success'])) {
+            $this->getIo()->table($tableHeader, $result['success']);
 
-            $io->success(
+            $this->getIo()->success(
                 sprintf(
                     $this->trans('commands.create.vocabularies.messages.created-terms'),
-                    $limit
-                )
-            );
-        } else {
-            $io->error(
-                sprintf(
-                    $this->trans('commands.create.vocabularies.messages.error'),
-                    $vocabularies['error'][0]['error']
+                    count($result['success'])
                 )
             );
         }
 
+        if (isset($result['error'])) {
+            foreach ($result['error'] as $error) {
+                $this->getIo()->error(
+                    sprintf(
+                        $this->trans('commands.create.vocabularies.messages.error'),
+                        $error
+                    )
+                );
+            }
+        }
+
         return 0;
     }
 }