30 private $arrayManager;
37 private $preparedValueFactory;
49 $this->writer = $writer;
50 $this->arrayManager = $arrayManager;
65 $pathPrefix = $this->getPathPrefix($scope, $scopeCode);
74 foreach (
$values as $configPath => $configValue) {
75 $fullConfigPath = $pathPrefix . $configPath;
76 $backendModel = $this->preparedValueFactory->create($configPath, $configValue, $scope, $scopeCode);
78 if ($backendModel instanceof
Value) {
79 $backendModel->validateBeforeSave();
80 $backendModel->beforeSave();
81 $configValue = $backendModel->getValue();
82 $backendModel->afterSave();
85 $config = $this->setConfig(
$config, $fullConfigPath, $configValue);
88 $this->writer->saveConfig(
102 private function setConfig(array
$config, $configPath, $configValue)
104 if ($configValue ===
null) {
108 $config = $this->arrayManager->set(
126 private function getPathPrefix($scope, $scopeCode)
130 && !empty($scopeCode)
132 $pathPrefixes[] = $scopeCode;
135 return implode(
'/', $pathPrefixes) .
'/';
save(array $values, $scope=ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode=null)
__construct(Writer $writer, ArrayManager $arrayManager, PreparedValueFactory $valueFactory=null)