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\FixturesBundle\Command; |
13
|
|
|
|
14
|
|
|
use Sylius\Bundle\FixturesBundle\Fixture\FixtureRegistryInterface; |
15
|
|
|
use Sylius\Bundle\FixturesBundle\Suite\SuiteRegistryInterface; |
16
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Kamil Kokot <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
final class FixturesListCommand extends ContainerAwareCommand |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* {@inheritdoc} |
27
|
|
|
*/ |
28
|
|
|
protected function configure() |
29
|
|
|
{ |
30
|
|
|
$this |
31
|
|
|
->setName('sylius:fixtures:list') |
32
|
|
|
->setDescription('Lists available fixtures') |
33
|
|
|
; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
*/ |
39
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
40
|
|
|
{ |
41
|
|
|
$this->listSuites($output); |
42
|
|
|
$this->listFixtures($output); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param OutputInterface $output |
47
|
|
|
*/ |
48
|
|
|
private function listSuites(OutputInterface $output) |
49
|
|
|
{ |
50
|
|
|
$suites = $this->getSuiteRegistry()->getSuites(); |
51
|
|
|
|
52
|
|
|
$output->writeln('Available suites:'); |
53
|
|
|
|
54
|
|
|
foreach ($suites as $suite) { |
55
|
|
|
$output->writeln(' - ' . $suite->getName()); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param OutputInterface $output |
61
|
|
|
*/ |
62
|
|
|
private function listFixtures(OutputInterface $output) |
63
|
|
|
{ |
64
|
|
|
$fixtures = $this->getFixtureRegistry()->getFixtures(); |
65
|
|
|
|
66
|
|
|
$output->writeln('Available fixtures:'); |
67
|
|
|
|
68
|
|
|
foreach ($fixtures as $name => $fixture) { |
69
|
|
|
$output->writeln(' - ' . $name); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return SuiteRegistryInterface |
75
|
|
|
*/ |
76
|
|
|
private function getSuiteRegistry() |
77
|
|
|
{ |
78
|
|
|
return $this->getContainer()->get('sylius_fixtures.suite_registry'); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return FixtureRegistryInterface |
83
|
|
|
*/ |
84
|
|
|
private function getFixtureRegistry() |
85
|
|
|
{ |
86
|
|
|
return $this->getContainer()->get('sylius_fixtures.fixture_registry'); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|