forked from Toxantron/scrumonline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jira-controller.php
30 lines (25 loc) · 958 Bytes
/
jira-controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/*
* Jira controller class to handle all Jira operations
*/
class JiraController extends ControllerBase
{
public function getIssues()
{
$parameters = array_merge((array) $jiraConfiguration, $_POST);
$jiraUrl = $parameters['base_url'] . '/rest/api/2/search?jql=project=' . $parameters['project'];
if ($parameters['jql']) {
$jiraUrl .= ' and ' . $parameters['jql'];
}
if (substr_count(strtolower($parameters['jql']), "order by") == 0 && substr_count(strtolower($parameters['jql']), "order%20by") == 0) {
$jiraUrl .= ' order by priority';
}
$client = new GuzzleHttp\Client();
$res = $client->request('GET', $jiraUrl, [
'auth' => [$parameters['username'], $parameters['password']]
]);
$response = json_decode($res->getBody()->getContents(), true);
return $response;
}
}
return new JiraController($entityManager);