From: Jérémy Benoist Date: Fri, 28 Jul 2017 05:38:15 +0000 (+0200) Subject: Merge pull request #3291 from nclsHart/show-user-io X-Git-Tag: 2.3.0~31^2~33 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=233eb91be4bd381ff48de0a15aff94415a3f2797;hp=-c;p=github%2Fwallabag%2Fwallabag.git Merge pull request #3291 from nclsHart/show-user-io Better rendering for show user command using symfony style --- 233eb91be4bd381ff48de0a15aff94415a3f2797 diff --combined src/Wallabag/CoreBundle/Command/ShowUserCommand.php index 4511c235,33888fa3..090309d9 --- a/src/Wallabag/CoreBundle/Command/ShowUserCommand.php +++ b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php @@@ -7,12 -7,13 +7,13 @@@ use Symfony\Bundle\FrameworkBundle\Comm 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 Wallabag\UserBundle\Entity\User; class ShowUserCommand extends ContainerAwareCommand { - /** @var OutputInterface */ - protected $output; + /** @var SymfonyStyle */ + protected $io; protected function configure() { @@@ -29,7 -30,7 +30,7 @@@ protected function execute(InputInterface $input, OutputInterface $output) { - $this->output = $output; + $this->io = new SymfonyStyle($input, $output); $username = $input->getArgument('username'); @@@ -37,7 -38,7 +38,7 @@@ $user = $this->getUser($username); $this->showUser($user); } catch (NoResultException $e) { - $output->writeln(sprintf('User "%s" not found.', $username)); + $this->io->error(sprintf('User "%s" not found.', $username)); return 1; } @@@ -50,12 -51,14 +51,14 @@@ */ private function showUser(User $user) { - $this->output->writeln(sprintf('Username : %s', $user->getUsername())); - $this->output->writeln(sprintf('Email : %s', $user->getEmail())); - $this->output->writeln(sprintf('Display name : %s', $user->getName())); - $this->output->writeln(sprintf('Creation date : %s', $user->getCreatedAt()->format('Y-m-d H:i:s'))); - $this->output->writeln(sprintf('Last login : %s', $user->getLastLogin() !== null ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never')); - $this->output->writeln(sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no')); + $this->io->listing([ + sprintf('Username : %s', $user->getUsername()), + sprintf('Email : %s', $user->getEmail()), + sprintf('Display name : %s', $user->getName()), + sprintf('Creation date : %s', $user->getCreatedAt()->format('Y-m-d H:i:s')), + sprintf('Last login : %s', $user->getLastLogin() !== null ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never'), + sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no'), + ]); } /** @@@ -69,4 -72,9 +72,4 @@@ { return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username); } - - private function getDoctrine() - { - return $this->getContainer()->get('doctrine'); - } }