示例#1
0
文件: Tag.php 项目: edewaele/yapafo
 /**
  * @param SimpleXMLElement $xmlObj
  * @return OSM_Objects_Tag 
  */
 public static function fromXmlObj(SimpleXMLElement $xmlObj)
 {
     $tag = new OSM_Objects_Tag((string) $xmlObj['k'], (string) $xmlObj['v']);
     $tag->setDirty(false);
     return $tag;
 }
示例#2
0
 /**
  *
  * @param SimpleXMLElement $xmlObj
  * @return array List of processed children types to avoid reprocessing in sub class.
  */
 protected function _fromXmlObj(SimpleXMLElement $xmlObj)
 {
     foreach ($xmlObj->attributes() as $k => $v) {
         $this->_attrs[(string) $k] = (string) $v;
     }
     if (!array_key_exists('id', $this->_attrs)) {
         throw new OSM_Exception(__CLASS__ . ' should must a "id" attribute');
     }
     OSM_ZLog::debug(__METHOD__, 'Got a ' . __CLASS__ . ' with id=', $this->getId());
     foreach ($xmlObj->children() as $child) {
         switch ($child->getName()) {
             case OSM_Objects_Object::OBJTYPE_TAG:
                 OSM_ZLog::debug(__METHOD__, 'Found child: ', OSM_Objects_Object::OBJTYPE_TAG);
                 $tag = OSM_Objects_Tag::fromXmlObj($child);
                 $this->_tags[$tag->getKey()] = $tag;
                 break;
         }
     }
     return array(OSM_Objects_Object::OBJTYPE_TAG);
 }