public function PatchinfoDrupalorgService::getIssue in PatchInfo 8.2
Gets information about issue on drupal.org.
Parameters
string $issue_number: Issue number on drupal.org.
Return value
array Array with field information.
File
- modules/
patchinfo_drupalorg/ src/ PatchinfoDrupalorgService.php, line 64
Class
- PatchinfoDrupalorgService
- Class PatchinfoDrupalorgService contains commonly shared utilities.
Namespace
Drupal\patchinfo_drupalorgCode
public function getIssue(string $issue_number) {
$cid = 'drupalorgLookupIssue:' . $issue_number;
$cache = $this->cache
->get($cid);
if ($cache) {
return (array) $cache->data;
}
// Get url content from Guzzle.
$http_client = $this->httpClientFactory
->fromOptions([
'headers' => [
'Content-Type' => [
'application/json',
],
],
'timeout' => 10,
]);
$service_url = 'https://www.drupal.org/api-d7/node.json?nid=' . $issue_number;
try {
$response = $http_client
->request('GET', $service_url);
$reponse_body = $response
->getBody();
$decoded = json_decode($reponse_body);
if ($response
->getStatusCode() !== 200) {
drush_print('Error retrieving issue ' . $issue_number . ' , error:' . $response
->getReasonPhrase());
return [];
}
$composer_module_issue = reset($decoded->list);
$this->cache
->set($cid, $composer_module_issue, $this->time
->getRequestTime() + 3700);
return (array) $composer_module_issue;
} catch (RequestException $e) {
drush_print('Error retrieving issue ' . $issue_number . ' , error:' . $e
->getMessage());
return [];
} catch (GuzzleException $e) {
drush_print('Error retrieving issue ' . $issue_number . ' , error:' . $e
->getMessage());
return [];
}
}