ListCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
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