|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
5
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace eZ\Bundle\EzPublishCoreBundle\Command; |
|
8
|
|
|
|
|
9
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
|
10
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
11
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
12
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
13
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
14
|
|
|
use Symfony\Component\VarDumper\Dumper\CliDumper; |
|
15
|
|
|
use Symfony\Component\VarDumper\Dumper\HtmlDumper; |
|
16
|
|
|
|
|
17
|
|
|
class DebugConfigResolverCommand extends ContainerAwareCommand |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* {@inheritdoc}. |
|
21
|
|
|
*/ |
|
22
|
|
|
public function configure() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->setName('ezplatform:debug:config-resolver'); |
|
25
|
|
|
$this->setAliases(['ezplatform:debug:config']); |
|
26
|
|
|
$this->setDescription('Debug / Retrive parameter from Config Resolver'); |
|
27
|
|
|
$this->addArgument( |
|
28
|
|
|
'parameter', |
|
29
|
|
|
InputArgument::REQUIRED, |
|
30
|
|
|
'The configuration resolver parameter to return, for instance "languages" or "http_cache.purge_servers"' |
|
31
|
|
|
); |
|
32
|
|
|
$this->addOption( |
|
33
|
|
|
'json', |
|
34
|
|
|
'js', |
|
35
|
|
|
InputOption::VALUE_NONE, |
|
36
|
|
|
'Only return value, for automation / testing use on a single line in json format.' |
|
37
|
|
|
); |
|
38
|
|
|
$this->addOption( |
|
39
|
|
|
'scope', |
|
40
|
|
|
's', |
|
41
|
|
|
InputOption::VALUE_REQUIRED, |
|
42
|
|
|
'Set another scope (siteaccess) to use, alternative to usiong the global --siteaccess="sa" option.' |
|
43
|
|
|
); |
|
44
|
|
|
$this->addOption( |
|
45
|
|
|
'namespace', |
|
46
|
|
|
'ns', |
|
47
|
|
|
InputOption::VALUE_REQUIRED, |
|
48
|
|
|
'Set another namespace then default "ezsettings" used by siteaccess settings.' |
|
49
|
|
|
); |
|
50
|
|
|
$this->setHelp(<<<EOM |
|
51
|
|
|
Outputs a given config resolver parameter, more commonly known as a SiteAccess setting. |
|
52
|
|
|
|
|
53
|
|
|
By default it will give value depending on global <comment>--siteaccess="name"</comment> (default siteaccess is used if not set). |
|
54
|
|
|
|
|
55
|
|
|
However you can also manualy set <comment>--scope="name"</comment> yourself if you don't want to affect the siteaccess |
|
56
|
|
|
set by the system. And you can also override namespace to get something else then default "ezsettings" namespace using |
|
57
|
|
|
<comment>--namspece="ns"</comment> option. |
|
58
|
|
|
|
|
59
|
|
|
NOTE: To rather see *all* compiled siteaccess settings, use: <comment>debug:config ezpublish [system.default]</comment> |
|
60
|
|
|
|
|
61
|
|
|
EOM |
|
62
|
|
|
); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* {@inheritdoc}. |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
69
|
|
|
{ |
|
70
|
|
|
/** @var \eZ\Publish\Core\MVC\ConfigResolverInterface $configResolver */ |
|
71
|
|
|
$configResolver = $this->getContainer()->get('ezpublish.config.resolver'); |
|
72
|
|
|
$parameter = $input->getArgument('parameter'); |
|
73
|
|
|
$namespace = $input->getOption('namespace'); |
|
74
|
|
|
$scope = $input->getOption('scope'); |
|
75
|
|
|
|
|
76
|
|
|
if ($input->getOption('json')) { |
|
77
|
|
|
$output->write( |
|
78
|
|
|
json_encode( |
|
79
|
|
|
$configResolver->getParameter($parameter, $namespace, $scope) |
|
|
|
|
|
|
80
|
|
|
) |
|
81
|
|
|
); |
|
82
|
|
|
|
|
83
|
|
|
return; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** @var \eZ\Publish\Core\MVC\Symfony\SiteAccess $siteAccess */ |
|
87
|
|
|
$siteAccess = $this->getContainer()->get('ezpublish.siteaccess'); |
|
88
|
|
|
$output->writeln("<comment>SiteAccess name:</> " . $siteAccess->name); |
|
89
|
|
|
|
|
90
|
|
|
$output->writeln("<comment>Parameter:</comment>\n"); |
|
91
|
|
|
|
|
92
|
|
|
$dumper = new CliDumper(); |
|
93
|
|
|
$output->write( |
|
94
|
|
|
$dumper->dump( |
|
95
|
|
|
$configResolver->getParameter($parameter, $namespace, $scope), |
|
|
|
|
|
|
96
|
|
|
true |
|
97
|
|
|
) |
|
98
|
|
|
); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.