Completed
Push — master ( 79d213...eeff33 )
by Kamil
23:15
created

ListCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 6
dl 0
loc 40
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 23 3
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
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 Sylius\Bundle\ThemeBundle\Command;
13
14
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
15
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
16
use Symfony\Component\Console\Helper\Table;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
/**
21
 * @author Kamil Kokot <[email protected]>
22
 */
23
class ListCommand extends ContainerAwareCommand
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    protected function configure()
29
    {
30
        $this
31
            ->setName('sylius:theme:list')
32
            ->setDescription('Shows list of detected themes.')
33
        ;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    protected function execute(InputInterface $input, OutputInterface $output)
40
    {
41
        /** @var ThemeInterface[] $themes */
42
        $themes = $this->getContainer()->get('sylius.repository.theme')->findAll();
43
44
        if (0 === count($themes)) {
45
            $output->writeln('<error>There are no themes.</error>');
46
47
            return;
48
        }
49
50
        $output->writeln('<question>Succesfully loaded themes:</question>');
51
52
        $table = new Table($output);
53
        $table->setHeaders(['Title', 'Name', 'Path']);
54
55
        foreach ($themes as $theme) {
56
            $table->addRow([$theme->getTitle(), $theme->getName(), $theme->getPath()]);
57
        }
58
59
        $table->setStyle('borderless');
60
        $table->render();
61
    }
62
}
63