Completed
Push — 2.x-dev-kit ( 8d77e1 )
by
unknown
28:22 queued 25:50
created

ListHandlerCommand::getMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sonata package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\NotificationBundle\Command;
13
14
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
class ListHandlerCommand extends ContainerAwareCommand
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function configure()
24
    {
25
        $this->setName('sonata:notification:list-handler');
26
        $this->setDescription('List all consumers available');
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function execute(InputInterface $input, OutputInterface $output)
33
    {
34
        $output->writeln('<info>List of consumers available</info>');
35
        foreach ($this->getMetadata() as $type => $ids) {
36
            foreach ($ids as $id) {
37
                $output->writeln(sprintf('<info>%s</info> - <comment>%s</comment>', $type, $id));
38
            }
39
        }
40
41
        $output->writeln(' done!');
42
    }
43
44
    /**
45
     * @return array
46
     */
47
    private function getMetadata()
48
    {
49
        return $this->getContainer()->get('sonata.notification.consumer.metadata')->getInformations();
50
    }
51
}
52