Completed
Push — develop ( bff84d...4789a9 )
by Tom
05:15
created

ListCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace N98\Magento\Command\Admin\User;
4
5
use N98\Util\Console\Helper\Table\Renderer\RendererFactory;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class ListCommand extends AbstractAdminUserCommand
11
{
12 View Code Duplication
    protected function configure()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
    {
14
        $this
15
            ->setName('admin:user:list')
16
            ->setDescription('List admin users.')
17
            ->addOption(
18
                'format',
19
                null,
20
                InputOption::VALUE_OPTIONAL,
21
                'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']'
22
            )
23
        ;
24
    }
25
26
    /**
27
     * @param InputInterface  $input
28
     * @param OutputInterface $output
29
     *
30
     * @return int|void
31
     */
32
    protected function execute(InputInterface $input, OutputInterface $output)
33
    {
34
        $this->detectMagento($output, true);
35
        if (!$this->initMagento()) {
36
            return;
37
        }
38
39
        /** @var $userModel \Mage_Admin_Model_User  */
40
        $userModel = $this->getUserModel();
41
        $userList = $userModel->getCollection();
42
        $table = array();
43
        foreach ($userList as $user) {
44
            $table[] = array(
45
                $user->getId(),
46
                $user->getUsername(),
47
                $user->getEmail(),
48
                $user->getIsActive() ? 'active' : 'inactive',
49
            );
50
        }
51
        $this->getHelper('table')
52
            ->setHeaders(array('id', 'username', 'email', 'status'))
53
            ->renderByFormat($output, $table, $input->getOption('format'));
54
    }
55
}
56