Skip to content

Commit 31822bf

Browse files
committed
More fixes for siteAlias and various issues found in the api regarding limited result sets.
1 parent 65d4793 commit 31822bf

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/PleskX/Api/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function request($request, $mode = self::RESPONSE_SHORT)
163163
? call_user_func($this->_verifyResponseCallback, $xml)
164164
: $this->_verifyResponse($xml);
165165

166-
return (self::RESPONSE_FULL == $mode) ? $xml : $xml->xpath('//result');
166+
return (self::RESPONSE_FULL == $mode) ? $xml : $xml->xpath('//result')[0];
167167
}
168168

169169
/**

src/PleskX/Api/Operator/SiteAlias.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ public function get($site_id)
4444

4545
$filter = $get->addChild('filter');
4646
$filter->addChild('site-id',$site_id);
47-
$response = $this->_client->request($packet);
47+
$response = $this->_client->request($packet,$this->_client::RESPONSE_FULL);
4848

4949
return new Struct\Info($response);
50-
//$packet->saveXML('/var/www/vagrant/ataama_development/application/logs/ataama/development/portal/xml');
51-
return $response;
5250
}
5351

5452
public function delete($site_id)

src/PleskX/Api/Struct.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ protected function _initScalarProperties($apiResponse, array $properties)
3131

3232
$reflectionProperty = new \ReflectionProperty($this, $classPropertyName);
3333
$docBlock = $reflectionProperty->getDocComment();
34-
$propertyType = preg_replace('/^.+ @var ([a-z]+) .+$/', '\1', $docBlock);
3534

35+
/* There seems to be a bug in the api when it encounters a docBlock with a strlen of 0.
36+
* Continue if so.
37+
*/
38+
if(strlen($docBlock) == 0)
39+
continue;
40+
41+
$propertyType = preg_replace('/^.+ @var ([a-z]+) .+$/', '\1', $docBlock);
3642
if ('string' == $propertyType) {
3743
$value = (string)$value;
3844
} else if ('integer' == $propertyType) {

src/PleskX/Api/Struct/SiteAlias/Info.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public function __construct($apiResponse)
2020
$json = json_encode($apiResponse);
2121
$responses = json_decode($json);
2222

23-
if(array_key_exists(0,$responses)) {
24-
foreach ($responses as $response) {
23+
if(isset($responses->{'site-alias'}->get->result) && count($responses->{'site-alias'}->get->result) > 1) {
24+
foreach ($responses->{'site-alias'}->get->result as $response) {
2525
if(isset($response->info)) {
2626
$this->array[] = array(
27-
'site-name' => $response->info->name,
27+
'name' => $response->info->name,
2828
'ascii-name' => $response->info->{'ascii-name'}
2929
);
3030
}

0 commit comments

Comments
 (0)