src/helpers/ConfigurationUpdater.php
public function updateConfiguration($usePostData = true)
    {
        /** @var ApplicationConfigWriter[] $configWriters */
        $configWriters = [];
        foreach ($this->configs as $filename => $functionName) {
            $file = $this->generatedConfigsPath . $filename . '.php';
            $configWriters[$filename] = new ApplicationConfigWriter([
                'filename' => $file,
            ]);
        }
        $this->getConfigurables(true);
        $isValid = true;
        $errorSection = '';

        foreach ($this->_configurables as $configurable) {
            if (!isset($configurable['configurationModel'])) {
                continue;
            }
            /** @var BaseConfigurationModel $configurationModel */
            $configurationModel = new $configurable['configurationModel'];
            if (false === ExtensionsManager::module()->extensionIsActive($configurable['package'])) {
                $configurationModel->deleteFromState($this->configurablesStatePath);
                continue;
            } else {
                $configurationModel->loadState($this->configurablesStatePath);
            }
            $dataOk = true;
            if ($usePostData === true) {
                $dataOk = $configurationModel->load(Yii::$app->request->post());
            }
            if ($dataOk === true) {
                $event = new ConfigurationSaveEvent();
                $event->configurable = &$configurable;
                $event->configurationModel = &$configurationModel;
                $configurationModel->trigger($configurationModel->configurationSaveEvent(), $event);
                if ($event->isValid === true) {
                    if ($configurationModel->validate() === true) {
                        $configurationModel->saveState($this->configurablesStatePath);
                    } else {
                        if (Yii::$app->get('session', false)) {
                            Yii::$app->get('session')->setFlash(
                                'info',
                                'Validation error:' . var_export($configurationModel, true)
                            );
                        }
                        $isValid = false;
                    }
                } else {
                    $isValid = false;
                }
                if ($isValid === false) {
                    $errorSection = $configurable['sectionName'];
                    // event is valid, stop saving data
                    break;
                }
            } // model load from user input
            foreach ($configWriters as $filename => $writer) {
                $callbackFunction = $this->configs[$filename];
                $writer->addValues(call_user_func([$configurationModel, $callbackFunction]));
            }
        }  // /foreach

        if ($isValid === true) {
            // save all configurations
            $isValid = true;
            foreach ($configWriters as $writer) {
                $isValid = $isValid && $writer->commit();
            }
        }

        if (Yii::$app->get('session', false)) {
            if ($isValid === true) {
                Yii::$app->session->setFlash(
                    'success',
                    Yii::t(
                        'extensions-manager',
                        'Configuration saved'
                    )
                );
            } else {
                Yii::$app->session->setFlash(
                    'error',
                    Yii::t(
                        'extensions-manager',
                        'Error saving configuration for module {module}',
                        [
                            'module' => $errorSection,
                        ]
                    )
                );
            }
        }
        return $isValid;
    }
public function updateConfiguration($usePostData = true)
    {
        /** @var ApplicationConfigWriter[] $configWriters */
        $configWriters = [];
        foreach ($this->configs as $filename => $functionName) {
            $file = $this->generatedConfigsPath . $filename . '.php';
            $configWriters[$filename] = new ApplicationConfigWriter([
                'filename' => $file,
            ]);
        }
        $this->getConfigurables(true);
        $isValid = true;
        $errorSection = '';

        foreach ($this->_configurables as $configurable) {
            if (!isset($configurable['configurationModel'])) {
                continue;
            }
            /** @var BaseConfigurationModel $configurationModel */
            $configurationModel = new $configurable['configurationModel'];
            if (false === ExtensionsManager::module()->extensionIsActive($configurable['package'])) {
                $configurationModel->deleteFromState($this->configurablesStatePath);
                continue;
            } else {
                $configurationModel->loadState($this->configurablesStatePath);
            }
            $dataOk = true;
            if ($usePostData === true) {
                $dataOk = $configurationModel->load(Yii::$app->request->post());
            }
            if ($dataOk === true) {
                $event = new ConfigurationSaveEvent();
                $event->configurable = &$configurable;
                $event->configurationModel = &$configurationModel;
                $configurationModel->trigger($configurationModel->configurationSaveEvent(), $event);
                if ($event->isValid === true) {
                    if ($configurationModel->validate() === true) {
                        $configurationModel->saveState($this->configurablesStatePath);
                    } else {
                        if (Yii::$app->get('session', false)) {
                            Yii::$app->get('session')->setFlash(
                                'info',
                                'Validation error:' . var_export($configurationModel, true)
                            );
                        }
                        $isValid = false;
                    }
                } else {
                    $isValid = false;
                }
                if ($isValid === false) {
                    $errorSection = $configurable['sectionName'];
                    // event is valid, stop saving data
                    break;
                }
            } // model load from user input
            foreach ($configWriters as $filename => $writer) {
                $callbackFunction = $this->configs[$filename];
                $writer->addValues(call_user_func([$configurationModel, $callbackFunction]));
            }
        }  // /foreach

        if ($isValid === true) {
            // save all configurations
            $isValid = true;
            foreach ($configWriters as $writer) {
                $isValid = $isValid && $writer->commit();
            }
        }

        if (Yii::$app->get('session', false)) {
            if ($isValid === true) {
                Yii::$app->session->setFlash(
                    'success',
                    Yii::t(
                        'extensions-manager',
                        'Configuration saved'
                    )
                );
            } else {
                Yii::$app->session->setFlash(
                    'error',
                    Yii::t(
                        'extensions-manager',
                        'Error saving configuration for module {module}',
                        [
                            'module' => $errorSection,
                        ]
                    )
                );
            }
        }
        return $isValid;
    }
Updates all application configurations

@param bool $usePostData Should we populate all configurationModels with user-data
@param bool $loadCurrent if true current states will be loaded and merged with newly created model
otherwise configs will be just overwritten with data loaded from post if $usePostData === true
@return bool true if all is ok
@throws \yii\base\InvalidConfigException