@@ 46-66 (lines=21) @@ | ||
43 | * @param integer|string|null $value |
|
44 | * @return Struct\Info|Struct\Info[] |
|
45 | */ |
|
46 | private function _get($field = null, $value = null) |
|
47 | { |
|
48 | $packet = $this->_client->getPacket(); |
|
49 | $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); |
|
50 | ||
51 | $filterTag = $getTag->addChild('filter'); |
|
52 | if (!is_null($field)) { |
|
53 | $filterTag->addChild($field, $value); |
|
54 | } |
|
55 | ||
56 | $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); |
|
57 | ||
58 | $items = []; |
|
59 | foreach ($response->xpath('//result') as $xmlResult) { |
|
60 | $item = new Struct\Info($xmlResult->data); |
|
61 | $item->id = (int)$xmlResult->id; |
|
62 | $items[] = $item; |
|
63 | } |
|
64 | ||
65 | return $items; |
|
66 | } |
|
67 | ||
68 | } |
|
69 |
@@ 52-72 (lines=21) @@ | ||
49 | * @param integer|string $value |
|
50 | * @return Struct\Info[] |
|
51 | */ |
|
52 | 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 |