function quickupdate_get_project in Quick update 8
Same name and namespace in other branches
- 7 quickupdate.module \quickupdate_get_project()
Gets a project's information.
Parameters
string $project_name: The short name of the project to download.
Return value
array An array that contains the project's short name, title, download link, project type, and version.
1 call to quickupdate_get_project()
- quickupdate_manager_batch_project_get in ./
quickupdate.module - Batch callback: Downloads, unpacks, and verifies a project.
File
- ./
quickupdate.module, line 494 - Primarily Drupal hooks and global API functions.
Code
function quickupdate_get_project($project_name = '') {
$url = UPDATE_DEFAULT_URL . '/' . $project_name . '/' . DRUPAL_CORE_COMPATIBILITY;
module_load_include('inc', 'update', 'update.fetch');
$xml = Drupal::httpClient()
->get($url, array(
'Accept' => 'text/xml',
))
->send()
->getBody(TRUE);
$array = array();
if (!empty($xml)) {
$array = update_parse_xml($xml);
}
if (count($array) > 0 && isset($array['releases'])) {
$downloaded_major = isset($array['recommended_major']) ? $array['recommended_major'] : $array['default_major'];
foreach ($array['releases'] as $item) {
if ($item['status'] == 'published' && $item['version_major'] == $downloaded_major) {
$return = array();
$return['title'] = check_plain($array['title']);
$return['short_name'] = $array['short_name'];
$return['download_link'] = $item['download_link'];
$return['version'] = $item['version'];
return $return;
}
}
}
return array();
}