1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Magium\Configuration\Console\Command; |
4
|
|
|
|
5
|
|
|
use Magium\Configuration\Config\Config; |
6
|
|
|
use Magium\Configuration\MagiumConfigurationFactory; |
7
|
|
|
use Magium\Configuration\MagiumConfigurationFactoryInterface; |
8
|
|
|
use Symfony\Component\Console\Command\Command; |
9
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
10
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
11
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
12
|
|
|
|
13
|
|
|
class ConfigurationListKeys extends Command |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
const COMMAND = 'magium:configuration:list-keys'; |
17
|
|
|
|
18
|
|
|
const INITIAL_MESSAGE = 'Valid configuration keys'; |
19
|
|
|
|
20
|
|
|
protected $factory; |
21
|
|
|
|
22
|
3 |
|
protected function configure() |
23
|
|
|
{ |
24
|
|
|
$this |
25
|
3 |
|
->setName(self::COMMAND) |
26
|
3 |
|
->setDescription('List configuration settings') |
27
|
3 |
|
->setHelp("This command lists all of the configuration setting options") |
28
|
|
|
; |
29
|
3 |
|
} |
30
|
|
|
|
31
|
1 |
|
public function getConfigurationFactory() |
32
|
|
|
{ |
33
|
1 |
|
if (!$this->factory instanceof MagiumConfigurationFactoryInterface) { |
34
|
|
|
$this->factory = new MagiumConfigurationFactory(); |
35
|
|
|
} |
36
|
1 |
|
return $this->factory; |
37
|
|
|
} |
38
|
|
|
|
39
|
1 |
|
public function setConfigurationFactory(MagiumConfigurationFactoryInterface $factory) |
40
|
|
|
{ |
41
|
1 |
|
$this->factory = $factory; |
42
|
1 |
|
} |
43
|
|
|
|
44
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
45
|
|
|
{ |
46
|
1 |
|
$factory = $this->getConfigurationFactory(); |
47
|
1 |
|
$builder = $factory->getBuilder(); |
48
|
1 |
|
$merged = $builder->getMergedStructure(); |
49
|
1 |
|
$merged->registerXPathNamespace('s', 'http://www.magiumlib.com/Configuration'); |
50
|
1 |
|
$elements = $merged->xpath('//s:element'); |
51
|
1 |
|
$output->writeln(self::INITIAL_MESSAGE); |
52
|
1 |
|
foreach ($elements as $element) { |
53
|
1 |
|
$elementId = (string)$element['id']; |
54
|
1 |
|
$parent = $element->xpath('..'); |
55
|
1 |
|
$groupId = (string)$parent[0]['id']; |
56
|
1 |
|
$parent = $parent[0]->xpath('..'); |
57
|
1 |
|
$sectionId = (string)$parent[0]['id']; |
58
|
1 |
|
$description = ''; |
59
|
1 |
|
if (isset($element->description)) { |
60
|
1 |
|
$description = sprintf(' (%s)', (string)$element->description); |
61
|
|
|
} |
62
|
|
|
|
63
|
1 |
|
$out = sprintf('%s/%s/%s%s', $sectionId, $groupId, $elementId, $description); |
64
|
1 |
|
$output->writeln($out); |
65
|
|
|
|
66
|
|
|
} |
67
|
1 |
|
} |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
|