@@ 43-62 (lines=20) @@ | ||
40 | * @param integer|string $value |
|
41 | * @return Struct\Info[] |
|
42 | */ |
|
43 | public function getAll($field = null, $value = null) |
|
44 | { |
|
45 | $packet = $this->_client->getPacket(); |
|
46 | $getTag = $packet->addChild($this->_wrapperTag)->addChild('get_rec'); |
|
47 | ||
48 | $filterTag = $getTag->addChild('filter'); |
|
49 | if (!is_null($field)) { |
|
50 | $filterTag->addChild($field, $value); |
|
51 | } |
|
52 | $getTag->addChild('template'); |
|
53 | ||
54 | $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); |
|
55 | $items = []; |
|
56 | foreach ($response->xpath('//result') as $xmlResult) { |
|
57 | $item = new Struct\Info($xmlResult->data); |
|
58 | $item->id = (int)$xmlResult->id; |
|
59 | $items[] = $item; |
|
60 | } |
|
61 | return $items; |
|
62 | } |
|
63 | ||
64 | /** |
|
65 | * @param string $field |
@@ 60-83 (lines=24) @@ | ||
57 | * @param integer|string $value |
|
58 | * @return Struct\Info[] |
|
59 | */ |
|
60 | public function getAll($field = null, $value = null) |
|
61 | { |
|
62 | $packet = $this->_client->getPacket(); |
|
63 | $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); |
|
64 | ||
65 | $filterTag = $getTag->addChild('filter'); |
|
66 | if (!is_null($field)) { |
|
67 | $filterTag->addChild($field, $value); |
|
68 | } |
|
69 | ||
70 | $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); |
|
71 | ||
72 | $items = []; |
|
73 | foreach ($response->xpath('//result') as $xmlResult) { |
|
74 | if (empty($xmlResult->data)) { |
|
75 | continue; |
|
76 | } |
|
77 | $item = new Struct\Info($xmlResult->data); |
|
78 | $item->id = (int)$xmlResult->id; |
|
79 | $items[] = $item; |
|
80 | } |
|
81 | ||
82 | return $items; |
|
83 | } |
|
84 | } |
|
85 |