flagManager = $flagManager; $this->arrayUtils = $arrayUtils; $this->saveProcessor = $saveProcessor; $this->scopeConfig = $scopeConfig; $this->state = $state; $this->scope = $scope; } /** * Invokes saving of configurations when data was not imported before * or current value is different from previously imported. * * {@inheritdoc} * @since 101.0.0 */ public function import(array $data) { $currentScope = $this->scope->getCurrentScope(); try { $savedFlag = $this->flagManager->getFlagData(static::FLAG_CODE) ?: []; $changedData = array_replace_recursive( $this->arrayUtils->recursiveDiff($savedFlag, $data), $this->arrayUtils->recursiveDiff($data, $savedFlag) ); /** * Re-init config with new data. * This is required to load latest effective configuration value. */ if ($this->scopeConfig instanceof Config) { $this->scopeConfig->clean(); } $this->state->emulateAreaCode(Area::AREA_ADMINHTML, function () use ($changedData) { $this->scope->setCurrentScope(Area::AREA_ADMINHTML); // Invoke saving of new values. $this->saveProcessor->process($changedData); }); $this->scope->setCurrentScope($currentScope); $this->flagManager->saveFlag(static::FLAG_CODE, $data); } catch (\Exception $e) { throw new InvalidTransitionException(__('%1', $e->getMessage()), $e); } finally { $this->scope->setCurrentScope($currentScope); } return ['System config was processed']; } /** * @inheritdoc * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @since 101.0.0 */ public function getWarningMessages(array $data) { return []; } }