X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FCommand%2FShowUserCommand.php;h=87bccf7180eef4aa0a427cb690f02810cc4f4d4b;hb=8668796106b856ca041512af27268ce6e49d2caf;hp=0eeaabc443867b8a085a9a0df41930cfb5665f12;hpb=4e4a5b534ff241f25c35fad24c9c79eb12f4adde;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Command/ShowUserCommand.php b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php index 0eeaabc4..87bccf71 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; } @@ -45,17 +46,17 @@ class ShowUserCommand extends ContainerAwareCommand return 0; } - /** - * @param User $user - */ 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 (email) activated: %s', $user->isEmailTwoFactor() ? 'yes' : 'no'), + sprintf('2FA (OTP) activated: %s', $user->isGoogleAuthenticatorEnabled() ? 'yes' : 'no'), + ]); } /** @@ -67,11 +68,6 @@ class ShowUserCommand extends ContainerAwareCommand */ private function getUser($username) { - return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username); - } - - private function getDoctrine() - { - return $this->getContainer()->get('doctrine'); + return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username); } }