/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $entries = $this->repository->review(Review::ALL, TRUE); $helper = $this->getHelper('question'); $last = FALSE; $categories = $this->connector->fetchCategories(); $question = new ChoiceQuestion(sprintf('Select tag to use:[%s]', $last ?: Tag::DEFAULT_TAG), $categories, $last ?: Tag::DEFAULT_TAG); $tag_id = $helper->ask($input, $output, $question); $tag = $categories[$tag_id]; list(, $tag) = explode(':', $tag); foreach ($entries as $entry) { if ($entry->category) { continue; } $this->repository->tag($tag, $entry->id); $last = $tag; } if (!$last) { $output->writeln('<error>All items already tagged, use --retag to retag</error>'); } }
/** * Tag single entry. * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @param $slot_id */ protected function tagOne(InputInterface $input, OutputInterface $output, $slot_id) { if ($entry = $this->repository->slot($slot_id)) { $helper = $this->getHelper('question'); try { $title = $this->connector->ticketDetails($entry->tid); $categories = $this->connector->fetchCategories(); } catch (ConnectException $e) { $output->writeln('<error>You are offline, please try again later.</error>'); return; } $question = new ChoiceQuestion(sprintf('Enter tag for slot <comment>%d</comment> [<info>%d</info>]: %s [<info>%s h</info>] [%s]', $entry->id, $entry->tid, $title->getTitle(), Formatter::formatDuration($entry->end - $entry->start), static::DEFAULT_TAG), $categories, static::DEFAULT_TAG); $tag_id = $helper->ask($input, $output, $question); $tag = $categories[$tag_id]; list(, $tag) = explode(':', $tag); $this->repository->tag($tag, $entry->id); } else { $output->writeln('<error>No such slot - please check your slot ID</error>'); } }