Example #1
0
 public static function fromXML(SimpleXMLElement $xml)
 {
     $context = new ApiContext();
     $context->setDefault($xml['default'] == "true");
     $context->setId((string) $xml['id']);
     $context->setStatus(Status::fromXML($xml->status));
     $context->setMaxRateLimitTPMThreshold((int) $xml->maxRateLimitTPMThreshold);
     $context->setMaxRateLimitTPMWarning((int) $xml->maxRateLimitTPMWarning);
     $context->setMaxRateLimitTPSThreshold((int) $xml->maxRateLimitTPSThreshold);
     $context->setMaxRateLimitTPSWarning((int) $xml->maxRateLimitTPSWarning);
     if (!empty($xml->loadBalancing)) {
         $context->setLoadBalancing(LoadBalancing::fromXML($xml->loadBalancing));
     }
     $ths = array();
     foreach ($xml->targetHosts->targetHost as $targetHostXML) {
         $targetHost = TargetHost::fromXML($targetHostXML);
         $ths[] = $targetHost;
     }
     $context->setTargetHosts($ths);
     return $context;
 }