示例#1
0
 public static function fromDomElement(DOMNode $domNode)
 {
     $status = new GWTSiteSyncStatus();
     $xpath = new DOMXPath($domNode->ownerDocument);
     $contentSrc = $xpath->query($domNode->getNodePath() . "//*[local-name()='content']/@src");
     $verified = $xpath->query($domNode->getNodePath() . "//*[local-name()='verified']");
     $verificationMethod = $xpath->query($domNode->getNodePath() . "//*[local-name()='verification-method']");
     for ($i = 0; $i < $verificationMethod->length; $i++) {
         $node = $verificationMethod->item($i);
         if (preg_match('/google([a-f0-9]+)\\.html/', $node->nodeValue, $matches)) {
             $status->setPageVerificationCode($matches[1]);
         }
     }
     if ($contentSrc->length > 0) {
         $status->setUrl($contentSrc->item(0)->nodeValue);
     }
     if ($verified->length > 0) {
         $status->setVerified(self::parseBoolean($verified->item(0)->nodeValue));
     }
     return $status;
 }