Skip to content

Commit aba6e1f

Browse files
author
Bohdan Korablov
committed
MAGETWO-63382: CLI Improvements: Configuration management - Command config:show
1 parent e2a807a commit aba6e1f

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

app/code/Magento/Config/Console/Command/ConfigShowCommand.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ class ConfigShowCommand extends Command
5151
*/
5252
private $metadataProcessor;
5353

54-
/**
55-
* @var string
56-
*/
57-
private $сonfigPath;
58-
5954
/**
6055
* @param ValidatorInterface $scopeValidator
6156
* @param ConfigSourceInterface $configSource
@@ -77,7 +72,7 @@ public function __construct(
7772
}
7873

7974
/**
80-
* {@inheritdoc}
75+
* @inheritdoc
8176
*/
8277
protected function configure()
8378
{
@@ -117,11 +112,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
117112
{
118113
$scope = $input->getOption(self::INPUT_OPTION_SCOPE);
119114
$scopeCode = $input->getOption(self::INPUT_OPTION_SCOPE_CODE);
120-
$this->сonfigPath = $input->getArgument(self::INPUT_ARGUMENT_PATH);
115+
$inputPath = $input->getArgument(self::INPUT_ARGUMENT_PATH);
121116

122117
try {
123118
$this->scopeValidator->isValid($scope, $scopeCode);
124-
$configPath = $this->pathResolver->resolve($this->сonfigPath, $scope, $scopeCode);
119+
$configPath = $this->pathResolver->resolve($inputPath, $scope, $scopeCode);
125120
$configValue = $this->configSource->get($configPath);
126121
} catch (LocalizedException $e) {
127122
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
@@ -131,32 +126,34 @@ protected function execute(InputInterface $input, OutputInterface $output)
131126
if ($configValue === null) {
132127
$output->writeln(sprintf(
133128
'<error>%s</error>',
134-
__('Configuration for path: "%1" doesn\'t exist', $this->сonfigPath)->render()
129+
__('Configuration for path: "%1" doesn\'t exist', $inputPath)->render()
135130
));
136131
return Cli::RETURN_FAILURE;
137132
}
138133

139-
$this->outputResult($output, $configValue, $this->сonfigPath);
134+
$this->outputResult($input, $output, $configValue, $inputPath);
140135
return Cli::RETURN_SUCCESS;
141136
}
142137

143138
/**
144-
* Output single configuration value or list of values if array given.
139+
* Outputs single configuration value or list of values if array given.
145140
*
146-
* @param OutputInterface $output An OutputInterface instance
141+
* @param InputInterface $input an InputInterface instance
142+
* @param OutputInterface $output an OutputInterface instance
147143
* @param mixed $configValue single value or array of values
148144
* @param string $configPath base configuration path
149145
* @return void
150146
*/
151-
private function outputResult(OutputInterface $output, $configValue, $configPath)
147+
private function outputResult(InputInterface $input, OutputInterface $output, $configValue, $configPath)
152148
{
153149
if (!is_array($configValue)) {
154150
$value = $this->metadataProcessor->processValue($configValue, $configPath);
155-
$output->writeln($this->сonfigPath === $configPath ? $value : sprintf("%s - %s", $configPath, $value));
151+
$inputPath = $input->getArgument(self::INPUT_ARGUMENT_PATH);
152+
$output->writeln($inputPath === $configPath ? $value : sprintf("%s - %s", $configPath, $value));
156153
} else if (is_array($configValue)) {
157154
foreach ($configValue as $name => $value) {
158155
$childPath = empty($configPath) ? $name : ($configPath . '/' . $name);
159-
$this->outputResult($output, $value, $childPath);
156+
$this->outputResult($input, $output, $value, $childPath);
160157
}
161158
}
162159
}

app/code/Magento/Config/Test/Unit/Console/Command/ConfigShowCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ public function testConfigPathNotExist()
138138
}
139139

140140
/**
141-
* @param $configPath
142-
* @param mixed $scope
143-
* @param mixed $scopeCode
141+
* @param string $configPath
142+
* @param null|string $scope
143+
* @param null|string $scopeCode
144144
* @return CommandTester
145145
*/
146146
private function getConfigShowCommandTester($configPath, $scope = null, $scopeCode = null)

0 commit comments

Comments
 (0)