Skip to content

Commit 7626f9c

Browse files
committed
Fix incorrect XML creation for delete requests
1 parent 7f81b0c commit 7626f9c

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

src/Api/Operator.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ public function request($request, $mode = Client::RESPONSE_SHORT)
5454
*/
5555
protected function _delete($field, $value, $deleteMethodName = 'del')
5656
{
57-
$response = $this->request("$deleteMethodName.filter.$field=$value");
57+
$response = $this->request([
58+
$deleteMethodName => [
59+
'filter' => [
60+
$field => $value,
61+
],
62+
],
63+
]);
5864

5965
return 'ok' === (string) $response->status;
6066
}

src/Api/Operator/Webspace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function create(array $properties, array $hostingProperties = null, $plan
9696

9797
$response = $this->_client->request($packet);
9898

99-
return new Struct\Info($response);
99+
return new Struct\Info($response, $properties['name'] ?? '');
100100
}
101101

102102
/**

src/Api/Struct/Webspace/Info.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ class Info extends \PleskX\Api\Struct
1111
/** @var string */
1212
public $guid;
1313

14-
public function __construct($apiResponse)
14+
/** @var string */
15+
public $name;
16+
17+
public function __construct($apiResponse, $name = '')
1518
{
1619
$this->_initScalarProperties($apiResponse, [
1720
'id',
1821
'guid',
1922
]);
23+
$this->name = $name;
2024
}
2125
}

tests/WebspaceTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ public function testDelete()
8080
$this->assertTrue($result);
8181
}
8282

83+
public function testDeleteByName()
84+
{
85+
$webspace = static::_createWebspace();
86+
$result = static::$_client->webspace()->delete('name', $webspace->name);
87+
88+
$this->assertTrue($result);
89+
}
90+
8391
public function testRequestCreateWebspace()
8492
{
8593
$handlers = static::$_client->phpHandler()->getAll();

0 commit comments

Comments
 (0)