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
|
|
|
use ConfigurationFactoryTrait; |
16
|
|
|
|
17
|
|
|
const COMMAND = 'magium:configuration:list-keys'; |
18
|
|
|
|
19
|
|
|
const INITIAL_MESSAGE = 'Valid configuration keys'; |
20
|
|
|
|
21
|
3 |
|
protected function configure() |
22
|
|
|
{ |
23
|
|
|
$this |
24
|
3 |
|
->setName(self::COMMAND) |
25
|
3 |
|
->setDescription('List configuration settings') |
26
|
3 |
|
->setHelp("This command lists all of the configuration setting options") |
27
|
|
|
; |
28
|
3 |
|
} |
29
|
|
|
|
30
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
31
|
|
|
{ |
32
|
1 |
|
$factory = $this->getConfigurationFactory(); |
33
|
1 |
|
$builder = $factory->getBuilder(); |
34
|
1 |
|
$merged = $builder->getMergedStructure(); |
35
|
1 |
|
$merged->registerXPathNamespace('s', 'http://www.magiumlib.com/Configuration'); |
36
|
1 |
|
$elements = $merged->xpath('//s:element'); |
37
|
1 |
|
$output->writeln(self::INITIAL_MESSAGE); |
38
|
1 |
|
foreach ($elements as $element) { |
39
|
1 |
|
$elementId = (string)$element['id']; |
40
|
1 |
|
$parent = $element->xpath('..'); |
41
|
1 |
|
$groupId = (string)$parent[0]['id']; |
42
|
1 |
|
$parent = $parent[0]->xpath('..'); |
43
|
1 |
|
$sectionId = (string)$parent[0]['id']; |
44
|
1 |
|
$description = ''; |
45
|
1 |
|
if (isset($element->description)) { |
46
|
1 |
|
$description = sprintf(' (%s)', (string)$element->description); |
47
|
|
|
} |
48
|
|
|
|
49
|
1 |
|
$out = sprintf('%s/%s/%s%s', $sectionId, $groupId, $elementId, $description); |
50
|
1 |
|
$output->writeln($out); |
51
|
|
|
|
52
|
|
|
} |
53
|
1 |
|
} |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
|