1
|
|
|
<?php |
2
|
|
|
// Copyright 1999-2016. Parallels IP Holdings GmbH. |
3
|
|
|
|
4
|
|
|
namespace PleskX\Api\Operator; |
5
|
|
|
use PleskX\Api\Struct\Subdomain as Struct; |
6
|
|
|
|
7
|
|
|
class Subdomain extends \PleskX\Api\Operator |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @param array $properties |
11
|
|
|
* @return Struct\Info |
12
|
|
|
*/ |
13
|
|
|
public function create($properties) |
14
|
|
|
{ |
15
|
|
|
$packet = $this->_client->getPacket(); |
16
|
|
|
$info = $packet->addChild($this->_wrapperTag)->addChild('add'); |
17
|
|
|
|
18
|
|
|
foreach ($properties as $name => $value) { |
19
|
|
|
$info->addChild($name, $value); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
$response = $this->_client->request($packet); |
23
|
|
|
return new Struct\Info($response); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param string $field |
28
|
|
|
* @param integer|string $value |
29
|
|
|
* @return bool |
30
|
|
|
*/ |
31
|
|
|
public function delete($field, $value) |
32
|
|
|
{ |
33
|
|
|
return $this->_delete($field, $value); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param string $field |
38
|
|
|
* @param integer|string $value |
39
|
|
|
* @return Struct\Info |
40
|
|
|
*/ |
41
|
|
|
public function get($field, $value) |
42
|
|
|
{ |
43
|
|
|
$items = $this->getAll($field, $value); |
44
|
|
|
return reset($items); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param string $field |
49
|
|
|
* @param integer|string $value |
50
|
|
|
* @return Struct\Info[] |
51
|
|
|
*/ |
52
|
|
View Code Duplication |
public function getAll($field = null, $value = null) |
|
|
|
|
53
|
|
|
{ |
54
|
|
|
$packet = $this->_client->getPacket(); |
55
|
|
|
$getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); |
56
|
|
|
|
57
|
|
|
$filterTag = $getTag->addChild('filter'); |
58
|
|
|
if (!is_null($field)) { |
59
|
|
|
$filterTag->addChild($field, $value); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); |
63
|
|
|
|
64
|
|
|
$items = []; |
65
|
|
|
foreach ($response->xpath('//result') as $xmlResult) { |
66
|
|
|
$item = new Struct\Info($xmlResult->data); |
67
|
|
|
$item->id = (int)$xmlResult->id; |
68
|
|
|
$items[] = $item; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return $items; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|