Skip to content

Commit 3b33b1f

Browse files
committed
Merge branch 'master' into pr/45
# Conflicts: # src/Issue/IssueField.php
2 parents c027154 + 51adac3 commit 3b33b1f

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

src/Issue/IssueService.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,25 @@ public function getIssueFromJSON($json)
2424
*
2525
* @param $issueIdOrKey
2626
* @param array $paramArray Query Parameter key-value Array.
27+
* @param Issue $issueObject
2728
*
2829
* @return Issue class
2930
*
3031
* @throws JiraException
3132
* @throws \JsonMapper_Exception
3233
*/
33-
public function get($issueIdOrKey, $paramArray = [])
34+
public function get($issueIdOrKey, $paramArray = [], $issueObject = null)
3435
{
36+
$issueObject = ($issueObject) ? $issueObject : new Issue();
37+
3538
$queryParam = '?'.http_build_query($paramArray);
3639

3740
$ret = $this->exec($this->uri.'/'.$issueIdOrKey.$queryParam, null);
3841

3942
$this->log->addInfo("Result=\n".$ret);
4043

4144
return $issue = $this->json_mapper->map(
42-
json_decode($ret), new Issue()
45+
json_decode($ret), $issueObject
4346
);
4447
}
4548

src/JiraClient.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ class JiraClient
5858
* Constructor.
5959
*
6060
* @param ConfigurationInterface $configuration
61+
* @param Logger $logger
6162
*/
62-
public function __construct(ConfigurationInterface $configuration = null)
63+
public function __construct(ConfigurationInterface $configuration = null, Logger $logger = null)
6364
{
6465
if ($configuration === null) {
6566
$path = './';
@@ -74,11 +75,15 @@ public function __construct(ConfigurationInterface $configuration = null)
7475
$this->json_mapper = new \JsonMapper();
7576

7677
// create logger
77-
$this->log = new Logger('JiraClient');
78-
$this->log->pushHandler(new StreamHandler(
79-
$configuration->getJiraLogFile(),
80-
$this->convertLogLevel($configuration->getJiraLogLevel())
81-
));
78+
if ($logger) {
79+
$this->log = $logger;
80+
} else {
81+
$this->log = new Logger('JiraClient');
82+
$this->log->pushHandler(new StreamHandler(
83+
$configuration->getJiraLogFile(),
84+
$this->convertLogLevel($configuration->getJiraLogLevel())
85+
));
86+
}
8287

8388
$this->http_response = 200;
8489
}

src/User/UserService.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,27 @@ public function get($paramArray)
2727

2828
$this->log->addInfo("Result=\n".$ret);
2929

30-
return $issue = $this->json_mapper->map(
30+
return $this->json_mapper->map(
3131
json_decode($ret), new User()
3232
);
3333
}
34+
35+
public function search($paramArray)
36+
{
37+
$queryParam = '?'.http_build_query($paramArray);
38+
39+
$ret = $this->exec($this->uri.'/search'.$queryParam, null);
40+
41+
$this->log->addInfo("Result=\n".$ret);
42+
43+
$userData = json_decode($ret);
44+
$users = [];
45+
46+
foreach($userData as $user) {
47+
$users[] = $this->json_mapper->map(
48+
$user, new User()
49+
);
50+
}
51+
return $users;
52+
}
3453
}

0 commit comments

Comments
 (0)