ListCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 4 1
A execute() 0 9 2
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
namespace Zicht\Bundle\PageBundle\Command;
7
8
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
use Symfony\Component\Console\Input\InputInterface;
12
13
/**
14
 * List all page urls. Useful for testing.
15
 */
16
class ListCommand extends ContainerAwareCommand
17
{
18
    /**
19
     * @{inheritDoc}
20
     */
21
    protected function configure()
22
    {
23
        $this->setName('zicht:page:list')
24
            ->addOption('base-url', '', InputOption::VALUE_REQUIRED, 'Prepend a base url to the url\'s', null);
25
    }
26
27
    /**
28
     * @{inheritDoc}
29
     */
30
    protected function execute(InputInterface $input, OutputInterface $output)
31
    {
32
        $pages = $this->getContainer()->get('zicht_page.page_manager')->getBaseRepository()->findAll();
33
        $urlProvider = $this->getContainer()->get('zicht_url.provider');
34
35
        $baseUrl = rtrim($input->getOption('base-url'), '/');
36
37
        foreach ($pages as $page) {
38
            $output->writeln($baseUrl . $urlProvider->url($page));
39
        }
40
    }
41
}
42