preparedValueFactory = $preparedValueFactory; $this->deploymentConfig = $deploymentConfig; $this->configPathResolver = $configPathResolver; $this->configFactory = $configFactory ?? ObjectManager::getInstance()->get(ConfigFactory::class); } /** * Processes database flow of config:set command. * * Requires installed application. * * @inheritdoc * @since 101.0.0 */ public function process($path, $value, $scope, $scopeCode) { if ($this->isLocked($path, $scope, $scopeCode)) { throw new CouldNotSaveException( __( 'The value you set has already been locked. To change the value, use the --%1 option.', ConfigSetCommand::OPTION_LOCK_ENV ) ); } try { $config = $this->configFactory->create([ 'scope' => $scope, 'scope_code' => $scopeCode, ]); $config->setDataByPath($path, $value); $config->save(); } catch (\Exception $exception) { throw new CouldNotSaveException(__('%1', $exception->getMessage()), $exception); } } /** * Checks whether configuration is locked in file storage. * * @param string $path The path to configuration * @param string $scope The scope of configuration * @param string $scopeCode The scope code of configuration * @return bool */ private function isLocked($path, $scope, $scopeCode) { $scopePath = $this->configPathResolver->resolve($path, $scope, $scopeCode, System::CONFIG_TYPE); return $this->deploymentConfig->get($scopePath) !== null; } }