facade = $facade;
$this->changeDetector = $changeDetector;
$this->hash = $hash;
$this->emulatedAreaProcessor = $emulatedAreaProcessor;
parent::__construct();
}
/**
* @inheritdoc
*/
protected function configure()
{
$this->addArgument(
self::INPUT_ARGUMENT_PATH,
InputArgument::OPTIONAL,
'Configuration path for example group/section/field_name'
);
$this->addArgument(
self::INPUT_ARGUMENT_VALUE,
InputArgument::OPTIONAL,
'Configuration value'
);
$this->addOption(
self::INPUT_OPTION_INTERACTIVE,
'i',
InputOption::VALUE_NONE,
'Enable interactive mode to set all sensitive variables'
);
$this->addOption(
self::INPUT_OPTION_SCOPE,
null,
InputOption::VALUE_OPTIONAL,
'Scope for configuration, if not set use \'default\'',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
$this->addOption(
self::INPUT_OPTION_SCOPE_CODE,
null,
InputOption::VALUE_OPTIONAL,
'Scope code for configuration, empty string by default',
''
);
$this->setName('config:sensitive:set')
->setDescription('Set sensitive configuration values');
parent::configure();
}
/**
* @inheritdoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($this->changeDetector->hasChanges(System::CONFIG_TYPE)) {
$output->writeln(
''
. 'This command is unavailable right now. '
. 'To continue working with it please run app:config:import or setup:upgrade command before.'
. ''
);
return Cli::RETURN_FAILURE;
}
try {
$this->emulatedAreaProcessor->process(function () use ($input, $output) {
$this->facade->process($input, $output);
});
$this->hash->regenerate(System::CONFIG_TYPE);
return Cli::RETURN_SUCCESS;
} catch (\Exception $e) {
$output->writeln(
sprintf('%s', $e->getMessage())
);
return Cli::RETURN_FAILURE;
}
}
}