5 * Contains \Drupal\Console\Command\Create\TermsCommand.
8 namespace Drupal\Console\Command\Create;
10 use Symfony\Component\Console\Input\InputOption;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Drupal\Console\Core\Command\Command;
14 use Drupal\Console\Utils\Create\VocabularyData;
17 * Class VocabulariesCommand
19 * @package Drupal\Console\Command\Generate
21 class VocabulariesCommand extends Command
26 protected $vocabularyData;
29 * UsersCommand constructor.
31 * @param $vocabularyData
33 public function __construct(VocabularyData $vocabularyData)
35 $this->vocabularyData = $vocabularyData;
36 parent::__construct();
42 protected function configure()
45 ->setName('create:vocabularies')
46 ->setDescription($this->trans('commands.create.vocabularies.description'))
50 InputOption::VALUE_OPTIONAL,
51 $this->trans('commands.create.vocabularies.options.limit')
56 InputOption::VALUE_OPTIONAL,
57 $this->trans('commands.create.vocabularies.options.name-words')
58 )->setAliases(['crv']);
64 protected function interact(InputInterface $input, OutputInterface $output)
66 $limit = $input->getOption('limit');
68 $limit = $this->getIo()->ask(
69 $this->trans('commands.create.vocabularies.questions.limit'),
72 $input->setOption('limit', $limit);
75 $nameWords = $input->getOption('name-words');
77 $nameWords = $this->getIo()->ask(
78 $this->trans('commands.create.vocabularies.questions.name-words'),
82 $input->setOption('name-words', $nameWords);
89 protected function execute(InputInterface $input, OutputInterface $output)
91 $limit = $input->getOption('limit')?:25;
92 $nameWords = $input->getOption('name-words')?:5;
94 $result = $this->vocabularyData->create(
100 $this->trans('commands.create.vocabularies.messages.vocabulary-id'),
101 $this->trans('commands.create.vocabularies.messages.name'),
104 if (isset($result['success'])) {
105 $this->getIo()->table($tableHeader, $result['success']);
107 $this->getIo()->success(
109 $this->trans('commands.create.vocabularies.messages.created-terms'),
110 count($result['success'])
115 if (isset($result['error'])) {
116 foreach ($result['error'] as $error) {
117 $this->getIo()->error(
119 $this->trans('commands.create.vocabularies.messages.error'),