X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FCommand%2FShowUserCommand.php;h=a0184267e8fd632af356e068e956f73dfaabd04a;hb=3ef055ced3d6ea0d2f15ba660602545f477e9c3c;hp=eef04988fb80206d67bdf8c8a242299e188001b0;hpb=8c68acff2abe0573e287ad9ee4589668d1bb7ffa;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Command/ShowUserCommand.php b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php index eef04988..a0184267 100644 --- a/src/Wallabag/CoreBundle/Command/ShowUserCommand.php +++ b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php @@ -7,12 +7,13 @@ use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 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 @@ class ShowUserCommand extends ContainerAwareCommand protected function execute(InputInterface $input, OutputInterface $output) { - $this->output = $output; + $this->io = new SymfonyStyle($input, $output); $username = $input->getArgument('username'); @@ -37,7 +38,7 @@ class ShowUserCommand extends ContainerAwareCommand $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 @@ class ShowUserCommand extends ContainerAwareCommand */ 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', null !== $user->getLastLogin() ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never'), + sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no'), + ]); } /** @@ -69,9 +72,4 @@ class ShowUserCommand extends ContainerAwareCommand { return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username); } - - private function getDoctrine() - { - return $this->getContainer()->get('doctrine'); - } }