5 * Contains \Drupal\Console\Command\Create\TermsCommand.
8 namespace Drupal\Console\Command\Create;
10 use Drupal\Console\Core\Command\Shared\CommandTrait;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Input\InputInterface;
13 use Symfony\Component\Console\Output\OutputInterface;
14 use Symfony\Component\Console\Command\Command;
15 use Drupal\Console\Utils\Create\VocabularyData;
16 use Drupal\Console\Core\Style\DrupalStyle;
19 * Class VocabulariesCommand
21 * @package Drupal\Console\Command\Generate
23 class VocabulariesCommand extends Command
30 protected $vocabularyData;
33 * UsersCommand constructor.
35 * @param $vocabularyData
37 public function __construct(VocabularyData $vocabularyData)
39 $this->vocabularyData = $vocabularyData;
40 parent::__construct();
46 protected function configure()
49 ->setName('create:vocabularies')
50 ->setDescription($this->trans('commands.create.vocabularies.description'))
54 InputOption::VALUE_OPTIONAL,
55 $this->trans('commands.create.vocabularies.options.limit')
60 InputOption::VALUE_OPTIONAL,
61 $this->trans('commands.create.vocabularies.options.name-words')
68 protected function interact(InputInterface $input, OutputInterface $output)
70 $io = new DrupalStyle($input, $output);
72 $limit = $input->getOption('limit');
75 $this->trans('commands.create.vocabularies.questions.limit'),
78 $input->setOption('limit', $limit);
81 $nameWords = $input->getOption('name-words');
83 $nameWords = $io->ask(
84 $this->trans('commands.create.vocabularies.questions.name-words'),
88 $input->setOption('name-words', $nameWords);
95 protected function execute(InputInterface $input, OutputInterface $output)
97 $io = new DrupalStyle($input, $output);
99 $limit = $input->getOption('limit')?:25;
100 $nameWords = $input->getOption('name-words')?:5;
102 $vocabularies = $this->vocabularyData->create(
108 $this->trans('commands.create.vocabularies.messages.vocabulary-id'),
109 $this->trans('commands.create.vocabularies.messages.name'),
112 if (isset($vocabularies['success'])) {
113 $io->table($tableHeader, $vocabularies['success']);
117 $this->trans('commands.create.vocabularies.messages.created-terms'),
124 $this->trans('commands.create.vocabularies.messages.error'),
125 $vocabularies['error'][0]['error']