|
8 | 8 | use Magento\Config\App\Config\Type\System;
|
9 | 9 | use Magento\Config\Model\PreparedValueFactory;
|
10 | 10 | use Magento\Framework\App\Config\ConfigPathResolver;
|
| 11 | +use Magento\Framework\App\Config\Value; |
11 | 12 | use Magento\Framework\App\DeploymentConfig;
|
12 | 13 | use Magento\Framework\Config\File\ConfigFilePool;
|
13 | 14 | use Magento\Framework\Exception\CouldNotSaveException;
|
@@ -79,19 +80,27 @@ public function process($path, $value, $scope, $scopeCode)
|
79 | 80 | $configPath = $this->configPathResolver->resolve($path, $scope, $scopeCode, System::CONFIG_TYPE);
|
80 | 81 | $backendModel = $this->preparedValueFactory->create($path, $value, $scope, $scopeCode);
|
81 | 82 |
|
82 |
| - /** |
83 |
| - * Temporary solution until Magento introduce unified interface |
84 |
| - * for storing system configuration into database and configuration files. |
85 |
| - */ |
86 |
| - $backendModel->validateBeforeSave(); |
87 |
| - $backendModel->beforeSave(); |
| 83 | + if ($backendModel instanceof Value) { |
| 84 | + /** |
| 85 | + * Temporary solution until Magento introduce unified interface |
| 86 | + * for storing system configuration into database and configuration files. |
| 87 | + */ |
| 88 | + $backendModel->validateBeforeSave(); |
| 89 | + $backendModel->beforeSave(); |
88 | 90 |
|
89 |
| - $this->deploymentConfigWriter->saveConfig( |
90 |
| - [ConfigFilePool::APP_ENV => $this->arrayManager->set($configPath, [], $backendModel->getValue())], |
91 |
| - false |
92 |
| - ); |
| 91 | + $value = $backendModel->getValue(); |
93 | 92 |
|
94 |
| - $backendModel->afterSave(); |
| 93 | + $backendModel->afterSave(); |
| 94 | + |
| 95 | + /** |
| 96 | + * Because FS does not support transactions, |
| 97 | + * we'll write value just after all validations are triggered. |
| 98 | + */ |
| 99 | + $this->deploymentConfigWriter->saveConfig( |
| 100 | + [ConfigFilePool::APP_ENV => $this->arrayManager->set($configPath, [], $value)], |
| 101 | + false |
| 102 | + ); |
| 103 | + } |
95 | 104 | } catch (\Exception $exception) {
|
96 | 105 | throw new CouldNotSaveException(__('%1', $exception->getMessage()), $exception);
|
97 | 106 | }
|
|
0 commit comments