preparedValueFactory = $preparedValueFactory; $this->deploymentConfigWriter = $writer; $this->arrayManager = $arrayManager; $this->configPathResolver = $configPathResolver; $this->target = $target; } /** * Processes lock flow of config:set command. * Requires read access to filesystem. * * {@inheritdoc} */ public function process($path, $value, $scope, $scopeCode) { try { $configPath = $this->configPathResolver->resolve($path, $scope, $scopeCode, System::CONFIG_TYPE); $backendModel = $this->preparedValueFactory->create($path, $value, $scope, $scopeCode); if ($backendModel instanceof Value) { /** * Temporary solution until Magento introduce unified interface * for storing system configuration into database and configuration files. */ $backendModel->validateBeforeSave(); $backendModel->beforeSave(); $value = $backendModel->getValue(); $backendModel->afterSave(); /** * Because FS does not support transactions, * we'll write value just after all validations are triggered. */ $this->deploymentConfigWriter->saveConfig( [$this->target => $this->arrayManager->set($configPath, [], $value)], false ); } } catch (\Exception $exception) { throw new CouldNotSaveException(__('%1', $exception->getMessage()), $exception); } } }