Completed
Push — theme-bundle ( 7a7785...cf8fa7 )
by Kamil
18:13
created

ThemeDebugCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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 ThemeDebugCommand extends ContainerAwareCommand
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    protected function configure()
29
    {
30
        $this
31
            ->setName('sylius:theme:debug')
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.theme.repository')->findAll();
43
44
        if (0 === count($themes)) {
45
            $output->writeln('<error>There are no themes.</error>');
46
            return;
47
        }
48
49
        $output->writeln('<question>Succesfully loaded themes:</question>');
50
51
        $table = new Table($output);
52
        $table->setHeaders(['Name', 'Slug', 'Path']);
53
54
        foreach ($themes as $theme) {
55
            $table->addRow([$theme->getName(), $theme->getSlug(), $theme->getPath()]);
56
        }
57
58
        $table->setStyle('borderless');
59
        $table->render();
60
    }
61
}
62