function _patchinfo_process_module in PatchInfo 8
Same name and namespace in other branches
- 8.2 patchinfo.module \_patchinfo_process_module()
- 7 patchinfo.module \_patchinfo_process_module()
Process patch information for a module.
Parameters
string $module: Machine readable module name.
array $patch_info: Patch info from module info.yml file.
1 call to _patchinfo_process_module()
- patchinfo_system_info_alter in ./
patchinfo.module - Implements hook_system_info_alter().
File
- ./
patchinfo.module, line 215 - Patch Info primary module file.
Code
function _patchinfo_process_module($module, array $patch_info) {
if (!empty($module)) {
foreach ($patch_info as $key => $info) {
// Calculate an index for each patch, which is not 0.
$index = $key + 1;
// If a colon is used in the patch description and the user didn't enclose
// the patch entry in single quotes as shown in the README file, the entry
// is interpreted by the YAML parser as an array. To prevent possible
// database exceptions, we replace the actual information with a warning
// message instructing the user to check his info.yml file syntax.
if (is_array($info)) {
\Drupal::logger('patchinfo')
->warning(t('Malformed patch entry detected in @module.info.yml at index @key. Check the syntax or your info.yml file! In most cases, this may be fixed by enclosing the patch entry in single or double quotes.', [
'@module' => $module,
'@key' => $key,
]));
$info = t('Malformed patch entry detected. Check the syntax of your info.yml file! In most cases, this may be fixed by enclosing the patch entry in single or double quotes.');
}
// Extract URL from patch information, if any.
$info = explode(' ', $info);
$url = '';
if (filter_var($info[0], FILTER_VALIDATE_URL) !== FALSE) {
$url = $info[0];
unset($info[0]);
}
$info = implode(' ', $info);
// Write patch information to db.
db_merge('patchinfo')
->key([
'module' => $module,
'id' => $index,
])
->fields([
'url' => $url,
'info' => $info,
])
->execute();
}
}
}