Skip to content

Commit e340e09

Browse files
authored
Merge pull request #392 from Art4/deprecate-abstractapi-delete
Deprecate `AbstractApi::delete()`
2 parents 3940781 + eab16f5 commit e340e09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1287
-611
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- `Redmine\Api\AbstractApi::get()` is deprecated, use `\Redmine\Http\HttpClient::request()` instead.
3232
- `Redmine\Api\AbstractApi::post()` is deprecated, use `\Redmine\Http\HttpClient::request()` instead.
3333
- `Redmine\Api\AbstractApi::put()` is deprecated, use `\Redmine\Http\HttpClient::request()` instead.
34+
- `Redmine\Api\AbstractApi::delete()` is deprecated, use `\Redmine\Http\HttpClient::request()` instead.
3435
- The constant `Redmine\Api\Issue::PRIO_LOW` is deprecated.
3536
- The constant `Redmine\Api\Issue::PRIO_NORMAL` is deprecated.
3637
- The constant `Redmine\Api\Issue::PRIO_HIGH` is deprecated.

src/Redmine/Api/AbstractApi.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,17 @@ protected function put($path, $data)
208208
/**
209209
* Perform the client delete() method.
210210
*
211+
* @deprecated v2.6.0 Use `\Redmine\Http\HttpClient::request()` instead
212+
* @see \Redmine\Http\HttpClient::request()
213+
*
211214
* @param string $path
212215
*
213216
* @return string
214217
*/
215218
protected function delete($path)
216219
{
220+
@trigger_error('`' . __METHOD__ . '()` is deprecated since v2.6.0, use `\Redmine\Http\HttpClient::request()` instead.', E_USER_DEPRECATED);
221+
217222
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeRequest(
218223
'DELETE',
219224
strval($path),

src/Redmine/Api/Attachment.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,15 @@ public function upload($attachment, $params = [])
132132
*
133133
* @param int $id id of the attachment
134134
*
135-
* @return false|SimpleXMLElement|string
135+
* @return string empty string on success
136136
*/
137137
public function remove($id)
138138
{
139-
return $this->delete('/attachments/' . urlencode(strval($id)) . '.xml');
139+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeXmlRequest(
140+
'DELETE',
141+
'/attachments/' . urlencode(strval($id)) . '.xml'
142+
));
143+
144+
return $this->lastResponse->getContent();
140145
}
141146
}

src/Redmine/Api/Group.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,16 @@ public function show($id, array $params = [])
203203
*
204204
* @param int $id id of the group
205205
*
206-
* @return string
206+
* @return string empty string on success
207207
*/
208208
public function remove($id)
209209
{
210-
return $this->delete('/groups/' . $id . '.xml');
210+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeXmlRequest(
211+
'DELETE',
212+
'/groups/' . $id . '.xml'
213+
));
214+
215+
return $this->lastResponse->getContent();
211216
}
212217

213218
/**
@@ -245,10 +250,15 @@ public function addUser($id, $userId)
245250
* @param int $id id of the group
246251
* @param int $userId id of the user
247252
*
248-
* @return string
253+
* @return string empty string on success
249254
*/
250255
public function removeUser($id, $userId)
251256
{
252-
return $this->delete('/groups/' . $id . '/users/' . $userId . '.xml');
257+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeXmlRequest(
258+
'DELETE',
259+
'/groups/' . $id . '/users/' . $userId . '.xml'
260+
));
261+
262+
return $this->lastResponse->getContent();
253263
}
254264
}

src/Redmine/Api/Issue.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,16 @@ public function addWatcher($id, $watcherUserId)
296296
* @param int $id
297297
* @param int $watcherUserId
298298
*
299-
* @return false|SimpleXMLElement|string
299+
* @return string empty string on success
300300
*/
301301
public function removeWatcher($id, $watcherUserId)
302302
{
303-
return $this->delete('/issues/' . urlencode(strval($id)) . '/watchers/' . urlencode(strval($watcherUserId)) . '.xml');
303+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeXmlRequest(
304+
'DELETE',
305+
'/issues/' . urlencode(strval($id)) . '/watchers/' . urlencode(strval($watcherUserId)) . '.xml'
306+
));
307+
308+
return $this->lastResponse->getContent();
304309
}
305310

306311
/**
@@ -434,11 +439,16 @@ public function attachMany($id, array $attachments)
434439
*
435440
* @param int $id the issue number
436441
*
437-
* @return false|SimpleXMLElement|string
442+
* @return string empty string on success
438443
*/
439444
public function remove($id)
440445
{
441-
return $this->delete('/issues/' . urlencode(strval($id)) . '.xml');
446+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeXmlRequest(
447+
'DELETE',
448+
'/issues/' . urlencode(strval($id)) . '.xml'
449+
));
450+
451+
return $this->lastResponse->getContent();
442452
}
443453

444454
/**

src/Redmine/Api/IssueCategory.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,15 @@ public function update($id, array $params)
230230
* @param int $id id of the category
231231
* @param array $params extra GET parameters
232232
*
233-
* @return string
233+
* @return string empty string on success
234234
*/
235235
public function remove($id, array $params = [])
236236
{
237-
return $this->delete(
237+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeXmlRequest(
238+
'DELETE',
238239
PathSerializer::create('/issue_categories/' . urlencode(strval($id)) . '.xml', $params)->getPath()
239-
);
240+
));
241+
242+
return $this->lastResponse->getContent();
240243
}
241244
}

src/Redmine/Api/IssueRelation.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,16 @@ public function show($id)
118118
*
119119
* @param int $id the relation id
120120
*
121-
* @return string
121+
* @return string empty string on success
122122
*/
123123
public function remove($id)
124124
{
125-
return $this->delete('/relations/' . $id . '.xml');
125+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeXmlRequest(
126+
'DELETE',
127+
'/relations/' . $id . '.xml'
128+
));
129+
130+
return $this->lastResponse->getContent();
126131
}
127132

128133
/**

src/Redmine/Api/Membership.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,16 @@ public function update($id, array $params = [])
163163
*
164164
* @param int $id id of the membership
165165
*
166-
* @return false|\SimpleXMLElement|string
166+
* @return string empty string on success
167167
*/
168168
public function remove($id)
169169
{
170-
return $this->delete('/memberships/' . $id . '.xml');
170+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeXmlRequest(
171+
'DELETE',
172+
'/memberships/' . $id . '.xml'
173+
));
174+
175+
return $this->lastResponse->getContent();
171176
}
172177

173178
/**

src/Redmine/Api/Project.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,15 @@ protected function prepareParamsXml($params)
392392
*
393393
* @param int $id id of the project
394394
*
395-
* @return false|\SimpleXMLElement|string
395+
* @return string empty string on success
396396
*/
397397
public function remove($id)
398398
{
399-
return $this->delete('/projects/' . $id . '.xml');
399+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeXmlRequest(
400+
'DELETE',
401+
'/projects/' . $id . '.xml'
402+
));
403+
404+
return $this->lastResponse->getContent();
400405
}
401406
}

src/Redmine/Api/TimeEntry.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,15 @@ public function update($id, array $params)
187187
*
188188
* @param int $id id of the time entry
189189
*
190-
* @return false|\SimpleXMLElement|string
190+
* @return string empty string on success
191191
*/
192192
public function remove($id)
193193
{
194-
return $this->delete('/time_entries/' . $id . '.xml');
194+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeXmlRequest(
195+
'DELETE',
196+
'/time_entries/' . $id . '.xml'
197+
));
198+
199+
return $this->lastResponse->getContent();
195200
}
196201
}

0 commit comments

Comments
 (0)