Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListSubscriptions check status #54

Open
ilievsoft opened this issue Mar 15, 2017 · 0 comments
Open

ListSubscriptions check status #54

ilievsoft opened this issue Mar 15, 2017 · 0 comments

Comments

@ilievsoft
Copy link

ilievsoft commented Mar 15, 2017

You have to check the status of each subscription before calling the children() method on each iteration. Subscription with status error gives a fatal error of the PHP script since it does not have any children...
`protected function processResponse($xml)
{
$result = [];

    for ($i = 0; $i < count($xml->webspace->get->result); $i++) {
        $webspace = $xml->webspace->get->result[$i];
        
        if ( $webspace->status  != "ok" )
            continue;
        
        foreach ($webspace->data->hosting->children() as $host) {
            $hosting[$host->getName()] = Xml::getProperties($host);
        }

        $subscriptions = [];
        foreach ($webspace->data->subscriptions->children() as $subscription) {
            $subscriptions[] = [
                'locked' => (bool)$subscription->locked,
                'synchronized' => (bool)$subscription->synchronized,
                'plan-guid' => (string)$subscription->plan->{"plan-guid"},
            ];
        }

        $result[] = [
            'id' => (string)$webspace->id,
            'status' => (string)$webspace->status,
            'subscription_status' => (int)$webspace->data->gen_info->status,
            'created' => (string)$webspace->data->gen_info->cr_date,
            'name' => (string)$webspace->data->gen_info->name,
            'owner_id' => (string)$webspace->data->gen_info->{"owner-id"},
            'hosting' => $hosting,
            'real_size' => (int)$webspace->data->gen_info->real_size,
            'dns_ip_address' => (string)$webspace->data->gen_info->dns_ip_address,
            'htype' => (string)$webspace->data->gen_info->htype,
            'subscriptions' => $subscriptions,
        ];
    }

    return $result;
}`

So I just put a simple check:

if ( $webspace->status != "ok" ) continue;

And it is OK.
Thanks for committing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant