function _patchinfo_get_info in PatchInfo 8.2
Same name and namespace in other branches
- 8 patchinfo.module \_patchinfo_get_info()
- 7 patchinfo.module \_patchinfo_get_info()
Get patch information from DB.
Parameters
bool $raw: If TRUE, uses an array containing url and info keys for each patch. If FALSE (default), either use info text only or, if a URL is available, a suitable link for each patch.
Return value
array Array of patches in DB keyed by machine readable module name.
4 calls to _patchinfo_get_info()
- drush_patchinfo_list in ./
patchinfo.drush.inc - Command callback for patchinfo-list command.
- PatchInfoCommands::getTableData in src/
Commands/ PatchInfoCommands.php - Returns table data for all patches in projects.
- patchinfo_form_update_manager_update_form_alter in ./
patchinfo.module - Implements hook_form_FORM_ID_alter() for update_manager_update_form().
- patchinfo_preprocess_update_project_status in ./
patchinfo.module - Implements hook_preprocess_HOOK() for update-project-status.html.twig.
File
- ./
patchinfo.module, line 199 - Patch Info primary module file.
Code
function _patchinfo_get_info($raw = FALSE) {
$patch_info = [];
$result = \Drupal::database()
->select('patchinfo', 'pi')
->fields('pi', [
'module',
'id',
'url',
'info',
'source',
])
->execute();
foreach ($result as $row) {
if (!isset($patch_info[$row->module])) {
$patch_info[$row->module] = [];
}
if ($raw) {
$patch_info[$row->module][] = [
'url' => $row->url,
'info' => $row->info,
'source' => $row->source,
];
}
else {
if (!empty($row->url)) {
$url = Url::fromUri($row->url);
$text = $row->info;
if (!empty($row->source)) {
$text = t('@text <abbr title="@source">(src)</abbr>', [
'@text' => $row->info,
'@source' => $row->source,
]);
}
$patch_info[$row->module][] = Link::fromTextAndUrl($text, $url);
}
else {
$text = Html::escape($row->info);
if (!empty($row->source)) {
$text = t('@text <abbr title="@source">(src)</abbr>', [
'@text' => $row->info,
'@source' => $row->source,
]);
}
$patch_info[$row->module][] = $text;
}
}
}
return $patch_info;
}