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

ListHandlerCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 5
c 2
b 1
f 0
lcom 0
cbo 3
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMetadata() 0 4 1
A configure() 0 5 1
A execute() 0 11 3
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