14 use Symfony\Component\Console\Command\Command;
15 use Symfony\Component\Console\Input\InputArgument;
16 use Symfony\Component\Console\Input\InputInterface;
17 use Symfony\Component\Console\Input\InputOption;
18 use Symfony\Component\Console\Output\OutputInterface;
37 private $scopeValidator;
44 private $configSource;
51 private $pathResolver;
58 private $valueProcessor;
94 parent::__construct();
95 $this->scopeValidator = $scopeValidator;
96 $this->configSource = $configSource;
97 $this->pathResolver = $pathResolver;
98 $this->valueProcessor = $valueProcessor;
108 self::INPUT_ARGUMENT_PATH,
109 InputArgument::OPTIONAL,
110 'Configuration path, for example section_id/group_id/field_id' 113 self::INPUT_OPTION_SCOPE,
115 InputOption::VALUE_OPTIONAL,
116 'Scope for configuration, if not specified, then \'default\' scope will be used',
120 self::INPUT_OPTION_SCOPE_CODE,
122 InputOption::VALUE_OPTIONAL,
123 'Scope code (required only if scope is not `default`)',
126 $this->setName(
'config:show')
128 'Shows configuration value for given path. If path is not specified, all saved values will be shown' 145 $this->scope = $input->getOption(self::INPUT_OPTION_SCOPE);
146 $this->scopeCode = $input->getOption(self::INPUT_OPTION_SCOPE_CODE);
147 $this->inputPath = trim($input->getArgument(self::INPUT_ARGUMENT_PATH),
'/');
149 $this->scopeValidator->isValid($this->scope, $this->scopeCode);
150 $configPath = $this->pathResolver->resolve($this->inputPath, $this->scope, $this->scopeCode);
151 $configValue = $this->configSource->get($configPath);
153 if (empty($configValue)) {
156 __(
'Configuration for path: "%1" doesn\'t exist', $this->inputPath)->render()
161 $this->outputResult(
$output, $configValue, $this->inputPath);
163 }
catch (\Exception $e) {
164 $output->writeln(sprintf(
'<error>%s</error>', $e->getMessage()));
194 private function outputResult(OutputInterface
$output, $configValue, $configPath)
196 if (!is_array($configValue)) {
197 $value = $this->valueProcessor->process($this->scope, $this->scopeCode, $configValue, $configPath);
198 $output->writeln($this->inputPath === $configPath ?
$value : sprintf(
"%s - %s", $configPath,
$value));
199 }
elseif (is_array($configValue)) {
201 $childPath = empty($configPath) ?
$name : ($configPath .
'/' .
$name);
elseif(isset( $params[ 'redirect_parent']))
const INPUT_ARGUMENT_PATH
const INPUT_OPTION_SCOPE_CODE
execute(InputInterface $input, OutputInterface $output)
__construct(ValidatorInterface $scopeValidator, ConfigSourceInterface $configSource, ConfigPathResolver $pathResolver, ValueProcessor $valueProcessor)
if(!isset($_GET['name'])) $name