]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Command/ListUserCommand.php
Add list user command
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Command / ListUserCommand.php
1 <?php
2
3 namespace Wallabag\CoreBundle\Command;
4
5 use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6 use Symfony\Component\Console\Input\InputInterface;
7 use Symfony\Component\Console\Output\OutputInterface;
8 use Symfony\Component\Console\Style\SymfonyStyle;
9
10 class ListUserCommand extends ContainerAwareCommand
11 {
12 protected function configure()
13 {
14 $this
15 ->setName('wallabag:user:list')
16 ->setDescription('List all users')
17 ->setHelp('This command list all existing users')
18 ;
19 }
20
21 protected function execute(InputInterface $input, OutputInterface $output)
22 {
23 $io = new SymfonyStyle($input, $output);
24
25 $users = $this->getContainer()->get('wallabag_user.user_repository')->findAll();
26
27 $rows = [];
28 foreach ($users as $user) {
29 $rows[] = [
30 $user->getUsername(),
31 $user->getEmail(),
32 $user->isEnabled() ? 'yes' : 'no',
33 $user->hasRole('ROLE_SUPER_ADMIN') || $user->hasRole('ROLE_ADMIN') ? 'yes' : 'no',
34 ];
35 }
36
37 $io->table(['username', 'email', 'is enabled?', 'is admin?'], $rows);
38
39 $io->success(sprintf('%s user(s) displayed.', count($users)));
40
41 return 0;
42 }
43 }