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