public function ConfigurationUpdateGenerator::generate in Update helper 8
Same name in this branch
- 8 src/Generator/ConfigurationUpdateGenerator.php \Drupal\update_helper\Generator\ConfigurationUpdateGenerator::generate()
- 8 modules/update_helper_checklist/src/Generator/ConfigurationUpdateGenerator.php \Drupal\update_helper_checklist\Generator\ConfigurationUpdateGenerator::generate()
Generate patch file for listed modules in module defined for command.
Parameters
string $module_name: Module name where patch will be placed.
string $update_number: Update number that will be used.
string $module_list: Comma separated list of modules.
bool $from_active: Flag if configuration should be updated from active to Yml file configs.
Return value
bool Return if patch file is generated.
File
- src/
Generator/ ConfigurationUpdateGenerator.php, line 77
Class
- ConfigurationUpdateGenerator
- Configuration update generator for generate:configuration:update command.
Namespace
Drupal\update_helper\GeneratorCode
public function generate($module_name, $update_number, $module_list, $from_active) {
if ($module_list) {
$modules = explode(',', $module_list);
}
else {
$modules = array_filter($this->moduleHandler
->getModuleList(), function (Extension $extension) {
return $extension
->getType() == 'module';
});
$modules = array_keys($modules);
}
// Get patch data and save it into file.
$patch_data = $this->configHandler
->generatePatchFile($modules, $from_active);
if (!empty($patch_data)) {
$patch_file_path = $this->configHandler
->getPatchFile($module_name, $this
->getUpdateFunctionName($module_name, $update_number), TRUE);
if (file_put_contents($patch_file_path, $patch_data)) {
$this->fileQueue
->addFile($patch_file_path);
$new_code_line = count(file($patch_file_path));
$this->countCodeLines
->addCountCodeLines($new_code_line);
return TRUE;
}
}
return FALSE;
}