public function ConfigHandler::generatePatchFile in Update helper 8
Same name and namespace in other branches
- 2.x src/ConfigHandler.php \Drupal\update_helper\ConfigHandler::generatePatchFile()
Generate patch from changed configuration.
It compares Base vs. Active configuration and creates patch with defined name in patch folder.
Parameters
string[] $module_names: Module name that will be used to generate patch for it.
bool $from_active: Flag if configuration should be updated from active to file configs.
Return value
string|bool Rendering generated patch file name or FALSE if patch is empty.
File
- src/
ConfigHandler.php, line 128
Class
- ConfigHandler
- Configuration handler.
Namespace
Drupal\update_helperCode
public function generatePatchFile(array $module_names, $from_active) {
$update_patch = [];
foreach ($module_names as $module_name) {
$configuration_lists = $this->configList
->listConfig('module', $module_name);
// Get required and optional configuration names.
$module_config_names = array_merge($configuration_lists[1], $configuration_lists[2]);
$config_names = $this
->getConfigNames(array_intersect($module_config_names, $configuration_lists[0]));
foreach ($config_names as $config_name) {
$config_diff = $this
->getConfigDiff($config_name, $from_active);
$config_diff = $this
->filterDiff($config_diff);
if (!empty($config_diff)) {
$update_patch[$config_name
->getFullName()] = [
'expected_config' => $this
->getExpectedConfig($config_diff),
'update_actions' => $this
->getUpdateConfig($config_diff),
];
}
}
}
// We don't want to export configuration files in case we are making update
// front active configuration to configuration provided in files.
if (!$from_active) {
$this
->exportConfigurations(array_keys($update_patch));
}
return $update_patch ? $this->serializer::encode($update_patch) : FALSE;
}