From 37fb7e76d9186400ee22dda0928ee05d0bb8b9bb Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 27 Dec 2017 17:32:39 +0100 Subject: [PATCH] Simplified DisableKeyCommand using SymfonyStyle --- module/CLI/src/Command/Api/DisableKeyCommand.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/module/CLI/src/Command/Api/DisableKeyCommand.php b/module/CLI/src/Command/Api/DisableKeyCommand.php index 824229dd..386f838d 100644 --- a/module/CLI/src/Command/Api/DisableKeyCommand.php +++ b/module/CLI/src/Command/Api/DisableKeyCommand.php @@ -8,6 +8,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; use Zend\I18n\Translator\TranslatorInterface; class DisableKeyCommand extends Command @@ -40,18 +41,13 @@ class DisableKeyCommand extends Command public function execute(InputInterface $input, OutputInterface $output) { $apiKey = $input->getArgument('apiKey'); + $io = new SymfonyStyle($input, $output); try { $this->apiKeyService->disable($apiKey); - $output->writeln(sprintf( - $this->translator->translate('API key %s properly disabled'), - '' . $apiKey . '' - )); + $io->success(sprintf($this->translator->translate('API key "%s" properly disabled'), $apiKey)); } catch (\InvalidArgumentException $e) { - $output->writeln(sprintf( - '' . $this->translator->translate('API key "%s" does not exist.') . '', - $apiKey - )); + $io->error(sprintf($this->translator->translate('API key "%s" does not exist.'), $apiKey)); } } }