File tree Expand file tree Collapse file tree 3 files changed +36
-9
lines changed Expand file tree Collapse file tree 3 files changed +36
-9
lines changed Original file line number Diff line number Diff line change @@ -24,22 +24,25 @@ public function getIssueFromJSON($json)
24
24
*
25
25
* @param $issueIdOrKey
26
26
* @param array $paramArray Query Parameter key-value Array.
27
+ * @param Issue $issueObject
27
28
*
28
29
* @return Issue class
29
30
*
30
31
* @throws JiraException
31
32
* @throws \JsonMapper_Exception
32
33
*/
33
- public function get ($ issueIdOrKey , $ paramArray = [])
34
+ public function get ($ issueIdOrKey , $ paramArray = [], $ issueObject = null )
34
35
{
36
+ $ issueObject = ($ issueObject ) ? $ issueObject : new Issue ();
37
+
35
38
$ queryParam = '? ' .http_build_query ($ paramArray );
36
39
37
40
$ ret = $ this ->exec ($ this ->uri .'/ ' .$ issueIdOrKey .$ queryParam , null );
38
41
39
42
$ this ->log ->addInfo ("Result= \n" .$ ret );
40
43
41
44
return $ issue = $ this ->json_mapper ->map (
42
- json_decode ($ ret ), new Issue ()
45
+ json_decode ($ ret ), $ issueObject
43
46
);
44
47
}
45
48
Original file line number Diff line number Diff line change @@ -58,8 +58,9 @@ class JiraClient
58
58
* Constructor.
59
59
*
60
60
* @param ConfigurationInterface $configuration
61
+ * @param Logger $logger
61
62
*/
62
- public function __construct (ConfigurationInterface $ configuration = null )
63
+ public function __construct (ConfigurationInterface $ configuration = null , Logger $ logger = null )
63
64
{
64
65
if ($ configuration === null ) {
65
66
$ path = './ ' ;
@@ -74,11 +75,15 @@ public function __construct(ConfigurationInterface $configuration = null)
74
75
$ this ->json_mapper = new \JsonMapper ();
75
76
76
77
// 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
+ }
82
87
83
88
$ this ->http_response = 200 ;
84
89
}
Original file line number Diff line number Diff line change @@ -27,8 +27,27 @@ public function get($paramArray)
27
27
28
28
$ this ->log ->addInfo ("Result= \n" .$ ret );
29
29
30
- return $ issue = $ this ->json_mapper ->map (
30
+ return $ this ->json_mapper ->map (
31
31
json_decode ($ ret ), new User ()
32
32
);
33
33
}
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
+ }
34
53
}
You can’t perform that action at this time.
0 commit comments