|
6 | 6 | namespace Magento\Config\Console\Command;
|
7 | 7 |
|
8 | 8 | use Magento\Framework\App\Config\ConfigSourceInterface;
|
9 |
| -use Magento\Framework\App\Config\MetadataProcessor; |
10 | 9 | use Magento\Framework\App\Config\ScopeConfigInterface;
|
11 | 10 | use Magento\Framework\App\Config\ConfigPathResolver;
|
12 | 11 | use Magento\Framework\Exception\LocalizedException;
|
|
17 | 16 | use Symfony\Component\Console\Input\InputArgument;
|
18 | 17 | use Symfony\Component\Console\Input\InputOption;
|
19 | 18 | use Magento\Framework\Console\Cli;
|
| 19 | +use Magento\Config\Console\Command\ConfigShow\ValueProcessor; |
20 | 20 |
|
21 | 21 | /**
|
22 | 22 | * Command provides possibility to show system configuration.
|
@@ -47,28 +47,43 @@ class ConfigShowCommand extends Command
|
47 | 47 | private $pathResolver;
|
48 | 48 |
|
49 | 49 | /**
|
50 |
| - * @var MetadataProcessor |
| 50 | + * @var ValueProcessor |
51 | 51 | */
|
52 |
| - private $metadataProcessor; |
| 52 | + private $valueProcessor; |
| 53 | + |
| 54 | + /** |
| 55 | + * @var string |
| 56 | + */ |
| 57 | + private $scope; |
| 58 | + |
| 59 | + /** |
| 60 | + * @var string |
| 61 | + */ |
| 62 | + private $scopeCode; |
| 63 | + |
| 64 | + /** |
| 65 | + * @var string |
| 66 | + */ |
| 67 | + private $inputPath; |
53 | 68 |
|
54 | 69 | /**
|
55 | 70 | * @param ValidatorInterface $scopeValidator
|
56 | 71 | * @param ConfigSourceInterface $configSource
|
57 | 72 | * @param ConfigPathResolver $pathResolver
|
58 |
| - * @param MetadataProcessor $metadataProcessor |
| 73 | + * @param ValueProcessor $valueProcessor |
59 | 74 | * @internal param ScopeConfigInterface $appConfig
|
60 | 75 | */
|
61 | 76 | public function __construct(
|
62 | 77 | ValidatorInterface $scopeValidator,
|
63 | 78 | ConfigSourceInterface $configSource,
|
64 | 79 | ConfigPathResolver $pathResolver,
|
65 |
| - MetadataProcessor $metadataProcessor |
| 80 | + ValueProcessor $valueProcessor |
66 | 81 | ) {
|
67 | 82 | parent::__construct();
|
68 | 83 | $this->scopeValidator = $scopeValidator;
|
69 | 84 | $this->configSource = $configSource;
|
70 | 85 | $this->pathResolver = $pathResolver;
|
71 |
| - $this->metadataProcessor = $metadataProcessor; |
| 86 | + $this->valueProcessor = $valueProcessor; |
72 | 87 | }
|
73 | 88 |
|
74 | 89 | /**
|
@@ -110,50 +125,48 @@ protected function configure()
|
110 | 125 | */
|
111 | 126 | protected function execute(InputInterface $input, OutputInterface $output)
|
112 | 127 | {
|
113 |
| - $scope = $input->getOption(self::INPUT_OPTION_SCOPE); |
114 |
| - $scopeCode = $input->getOption(self::INPUT_OPTION_SCOPE_CODE); |
115 |
| - $inputPath = $input->getArgument(self::INPUT_ARGUMENT_PATH); |
| 128 | + $this->scope = $input->getOption(self::INPUT_OPTION_SCOPE); |
| 129 | + $this->scopeCode = $input->getOption(self::INPUT_OPTION_SCOPE_CODE); |
| 130 | + $this->inputPath = $input->getArgument(self::INPUT_ARGUMENT_PATH); |
116 | 131 |
|
117 | 132 | try {
|
118 |
| - $this->scopeValidator->isValid($scope, $scopeCode); |
119 |
| - $configPath = $this->pathResolver->resolve($inputPath, $scope, $scopeCode); |
| 133 | + $this->scopeValidator->isValid($this->scope, $this->scopeCode); |
| 134 | + $configPath = $this->pathResolver->resolve($this->inputPath, $this->scope, $this->scopeCode); |
120 | 135 | $configValue = $this->configSource->get($configPath);
|
121 | 136 | } catch (LocalizedException $e) {
|
122 | 137 | $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
|
123 | 138 | return Cli::RETURN_FAILURE;
|
124 | 139 | }
|
125 | 140 |
|
126 |
| - if ($configValue === null) { |
| 141 | + if (empty($configValue)) { |
127 | 142 | $output->writeln(sprintf(
|
128 | 143 | '<error>%s</error>',
|
129 |
| - __('Configuration for path: "%1" doesn\'t exist', $inputPath)->render() |
| 144 | + __('Configuration for path: "%1" doesn\'t exist', $this->inputPath)->render() |
130 | 145 | ));
|
131 | 146 | return Cli::RETURN_FAILURE;
|
132 | 147 | }
|
133 | 148 |
|
134 |
| - $this->outputResult($input, $output, $configValue, $inputPath); |
| 149 | + $this->outputResult($output, $configValue, $this->inputPath); |
135 | 150 | return Cli::RETURN_SUCCESS;
|
136 | 151 | }
|
137 | 152 |
|
138 | 153 | /**
|
139 | 154 | * Outputs single configuration value or list of values if array given.
|
140 | 155 | *
|
141 |
| - * @param InputInterface $input an InputInterface instance |
142 | 156 | * @param OutputInterface $output an OutputInterface instance
|
143 | 157 | * @param mixed $configValue single value or array of values
|
144 | 158 | * @param string $configPath base configuration path
|
145 | 159 | * @return void
|
146 | 160 | */
|
147 |
| - private function outputResult(InputInterface $input, OutputInterface $output, $configValue, $configPath) |
| 161 | + private function outputResult(OutputInterface $output, $configValue, $configPath) |
148 | 162 | {
|
149 | 163 | if (!is_array($configValue)) {
|
150 |
| - $value = $this->metadataProcessor->processValue($configValue, $configPath); |
151 |
| - $inputPath = $input->getArgument(self::INPUT_ARGUMENT_PATH); |
152 |
| - $output->writeln($inputPath === $configPath ? $value : sprintf("%s - %s", $configPath, $value)); |
153 |
| - } else if (is_array($configValue)) { |
| 164 | + $value = $this->valueProcessor->process($this->scope, $this->scopeCode, $configValue, $configPath); |
| 165 | + $output->writeln($this->inputPath === $configPath ? $value : sprintf("%s - %s", $configPath, $value)); |
| 166 | + } elseif (is_array($configValue)) { |
154 | 167 | foreach ($configValue as $name => $value) {
|
155 | 168 | $childPath = empty($configPath) ? $name : ($configPath . '/' . $name);
|
156 |
| - $this->outputResult($input, $output, $value, $childPath); |
| 169 | + $this->outputResult($output, $value, $childPath); |
157 | 170 | }
|
158 | 171 | }
|
159 | 172 | }
|
|
0 commit comments