예제 #1
0
 /**
  * Loads and parses xml
  *
  * @return CBitrixCloudCDNConfig
  * @throws CBitrixCloudException
  */
 public function loadRemoteXML()
 {
     //Get configuration from remote service
     $this->sites = CBitrixCloudOption::getOption("cdn_config_site")->getArrayValue();
     $this->domain = CBitrixCloudOption::getOption("cdn_config_domain")->getStringValue();
     $web_service = new CBitrixCloudCDNWebService($this->domain);
     $web_service->setDebug($this->debug);
     $obXML = $web_service->actionGetConfig();
     //
     // Parse it
     //
     $node = $obXML->SelectNodes("/control");
     if (is_object($node)) {
         $this->active = intval($node->getAttribute("active"));
         $this->expires = strtotime($node->getAttribute("expires"));
     } else {
         $this->active = 0;
         $this->expires = 0;
     }
     $node = $obXML->SelectNodes("/control/quota");
     if (is_object($node)) {
         $this->quota = CBitrixCloudCDNQuota::fromXMLNode($node);
     } else {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_CONFIG_XML_PARSE", array("#CODE#" => "2")));
     }
     $node = $obXML->SelectNodes("/control/classes");
     if (is_object($node)) {
         $this->classes = CBitrixCloudCDNClasses::fromXMLNode($node);
     } else {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_CONFIG_XML_PARSE", array("#CODE#" => "3")));
     }
     $node = $obXML->SelectNodes("/control/servergroups");
     if (is_object($node)) {
         $this->server_groups = CBitrixCloudCDNServerGroups::fromXMLNode($node);
     } else {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_CONFIG_XML_PARSE", array("#CODE#" => "4")));
     }
     $node = $obXML->SelectNodes("/control/locations");
     if (is_object($node)) {
         $this->locations = CBitrixCloudCDNLocations::fromXMLNode($node, $this);
     } else {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_CONFIG_XML_PARSE", array("#CODE#" => "5")));
     }
     return $this;
 }