Skip to content

Commit 6c76eb5

Browse files
committed
impl updateIssue
1 parent 034fda8 commit 6c76eb5

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "library",
55
"keywords": ["jira", "jira-php", "jira-rest"],
66
"require": {
7-
"php": ">=5.3",
7+
"php": ">=5.3.1",
88
"netresearch/jsonmapper": "0.4.*",
99
"monolog/monolog": "~1.12"
1010
},

src/JiraClient.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ private function convertLogLevel($log_level) {
5757
return Logger::INFO;
5858
}
5959

60+
// serilize only not null field.
61+
protected function filterNullVariable ($arr) {
62+
return array_filter((array) $arr, function ($val) {
63+
return (!is_null($val) && !empty($val) );
64+
});
65+
}
66+
6067
public function __construct($config)
6168
{
6269
$this->json_mapper = new \JsonMapper();

src/issue/IssueField.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ public function addVersion($id, $name) {
7575
return $this;
7676
}
7777

78+
public function addComment($comment) {
79+
if (is_null($this->comments))
80+
$this->comments = new \JiraRestApi\Issue\Comments();
81+
82+
array_push($this->versions, $v);
83+
return $this;
84+
}
85+
86+
//@TODO
87+
public function addLabel($label) {
88+
if (is_null($this->labels))
89+
$this->labels = array();
90+
91+
array_push($this->labels, $label);
92+
return $this;
93+
}
94+
7895
/** @var string */
7996
public $summary;
8097

@@ -121,7 +138,7 @@ public function addVersion($id, $name) {
121138
public $components;
122139

123140
/** @var Comments */
124-
public $comment;
141+
public $comments;
125142

126143
/** @var string */
127144
public $votes;

src/issue/IssueService.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ public function create($issueField) {
3737
$issue = new Issue();
3838

3939
// serilize only not null field.
40-
$issue->fields = array_filter((array) $issueField, function ($val) {
41-
return !is_null($val);
42-
});
43-
40+
$issue->fields = $this->filterNullVariable($issueField);
4441

4542
$data = json_encode($issue);
4643

@@ -79,26 +76,22 @@ public function addAttachments($issueIdOrKey, $filePath) {
7976
/**
8077
* update issue
8178
*
82-
* @param $issueKey Issue Key
79+
* @param $issueIdOrKey Issue Key
8380
* @param $issueField object of Issue class
8481
*
8582
* @return created issue key
8683
*/
87-
public function update($issueKey, $issueField) {
84+
public function update($issueIdOrKey, $issueField) {
8885
$issue = new Issue();
8986

90-
$issue->key = $issueKey;
91-
9287
// serilize only not null field.
93-
$issue->fields = array_filter((array) $issueField, function ($val) {
94-
return !is_null($val);
95-
});
88+
$issue->fields = $this->filterNullVariable($issueField);
9689

9790
$data = json_encode($issue);
9891

9992
$this->log->addInfo("Update Issue=\n" . $data );
10093

101-
$ret = $this->exec($this->uri . "/$issueIdOrKey/attachments", $data, "PUT");
94+
$ret = $this->exec($this->uri . "/$issueIdOrKey", $data, "PUT");
10295

10396
$issue = $this->json_mapper->map(
10497
json_decode($ret), new Issue()

0 commit comments

Comments
 (0)