| @@ 55-73 (lines=19) @@ | ||
| 52 | * @param string|null $keyId |
|
| 53 | * @return Struct\Info[] |
|
| 54 | */ |
|
| 55 | public function _get($keyId = null) |
|
| 56 | { |
|
| 57 | $packet = $this->_client->getPacket(); |
|
| 58 | $getTag = $packet->addChild($this->_wrapperTag)->addChild('get_info'); |
|
| 59 | ||
| 60 | $filterTag = $getTag->addChild('filter'); |
|
| 61 | if (!is_null($keyId)) { |
|
| 62 | $filterTag->addChild('key', $keyId); |
|
| 63 | } |
|
| 64 | ||
| 65 | $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); |
|
| 66 | ||
| 67 | $items = []; |
|
| 68 | foreach ($response->xpath('//result/key_info') as $keyInfo) { |
|
| 69 | $items[] = new Struct\Info($keyInfo); |
|
| 70 | } |
|
| 71 | ||
| 72 | return $items; |
|
| 73 | } |
|
| 74 | ||
| 75 | } |
|
| 76 | ||
| @@ 35-53 (lines=19) @@ | ||
| 32 | * @param integer|string|null $value |
|
| 33 | * @return Struct\Info|Struct\Info[] |
|
| 34 | */ |
|
| 35 | private function _get($field = null, $value = null) |
|
| 36 | { |
|
| 37 | $packet = $this->_client->getPacket(); |
|
| 38 | $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); |
|
| 39 | ||
| 40 | $filterTag = $getTag->addChild('filter'); |
|
| 41 | if (!is_null($field)) { |
|
| 42 | $filterTag->addChild($field, $value); |
|
| 43 | } |
|
| 44 | ||
| 45 | $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); |
|
| 46 | ||
| 47 | $items = []; |
|
| 48 | foreach ($response->xpath('//result') as $xmlResult) { |
|
| 49 | $items[] = new Struct\Info($xmlResult); |
|
| 50 | } |
|
| 51 | ||
| 52 | return $items; |
|
| 53 | } |
|
| 54 | ||
| 55 | } |
|
| 56 | ||
| @@ 17-31 (lines=15) @@ | ||
| 14 | * @param integer|string $value |
|
| 15 | * @return Info |
|
| 16 | */ |
|
| 17 | public function get($field, $value) |
|
| 18 | { |
|
| 19 | $packet = $this->_client->getPacket(); |
|
| 20 | $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); |
|
| 21 | $filterTag = $getTag->addChild('filter'); |
|
| 22 | ||
| 23 | if (!is_null($field)) { |
|
| 24 | $filterTag->addChild($field, $value); |
|
| 25 | } |
|
| 26 | ||
| 27 | $response = $this->_client->request($packet, Client::RESPONSE_FULL); |
|
| 28 | $xmlResult = $response->xpath('//result')[0]; |
|
| 29 | ||
| 30 | return new Info($xmlResult); |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @param string|null $field |
|
| @@ 38-56 (lines=19) @@ | ||
| 35 | * @param integer|string $value |
|
| 36 | * @return Info[] |
|
| 37 | */ |
|
| 38 | public function getAll($field = null, $value = null) |
|
| 39 | { |
|
| 40 | $packet = $this->_client->getPacket(); |
|
| 41 | $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); |
|
| 42 | ||
| 43 | $filterTag = $getTag->addChild('filter'); |
|
| 44 | if (!is_null($field)) { |
|
| 45 | $filterTag->addChild($field, $value); |
|
| 46 | } |
|
| 47 | ||
| 48 | $response = $this->_client->request($packet, Client::RESPONSE_FULL); |
|
| 49 | $items = []; |
|
| 50 | foreach ($response->xpath('//result') as $xmlResult) { |
|
| 51 | $item = new Info($xmlResult); |
|
| 52 | $items[] = $item; |
|
| 53 | } |
|
| 54 | ||
| 55 | return $items; |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||