Exemplo n.º 1
0
 /**
  * get single CustomerModel instance from a DOMElement
  *
  * @param DOMElement $node
  * @return CustomerModel
  */
 public static function fromDOMElement(DOMElement $node)
 {
     if ('CustomerModel' != $node->nodeName) {
         return new InvalidArgumentException('expected: CustomerModel, got: ' . $node->nodeName, 0);
     }
     $result = array();
     foreach (self::$FIELD_NAMES as $fieldName) {
         $n = $node->getElementsByTagName($fieldName)->item(0);
         if (!is_null($n)) {
             $result[$fieldName] = $n->nodeValue;
         }
     }
     $o = new CustomerModel();
     $o->assignByHash($result);
     $o->notifyPristine();
     return $o;
 }