Completed
Push — 3.x ( 1cd1d0...b03505 )
by Grégoire
16:27 queued 03:11
created

ListAdminCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\AdminBundle\Command;
15
16
use Sonata\AdminBundle\Admin\Pool;
17
use Symfony\Component\Console\Command\Command;
18
use Symfony\Component\Console\Input\InputInterface;
19
use Symfony\Component\Console\Output\OutputInterface;
20
21
/**
22
 * @author Thomas Rabaix <[email protected]>
23
 */
24
class ListAdminCommand extends Command
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    protected static $defaultName = 'sonata:admin:list';
30
31
    /**
32
     * @var Pool
33
     */
34
    private $pool;
35
36
    public function __construct(Pool $pool)
37
    {
38
        $this->pool = $pool;
39
40
        parent::__construct();
41
    }
42
43
    public function configure()
44
    {
45
        $this->setDescription('List all admin services available');
46
    }
47
48
    public function execute(InputInterface $input, OutputInterface $output)
49
    {
50
        $output->writeln('<info>Admin services:</info>');
51
        foreach ($this->pool->getAdminServiceIds() as $id) {
52
            $instance = $this->pool->getInstance($id);
53
            $output->writeln(sprintf('  <info>%-40s</info> %-60s',
54
                $id,
55
                $instance->getClass()
56
            ));
57
        }
58
    }
59
}
60