Esempio n. 1
0
 /**
  * Compute the member's key into the relation members collection.
  * 
  * @param string|OSM_Objects_Member $memberOrType
  * @param string $ref The member's ref. Should be null if $memberOrType instanceof OSM_Objects_Member .
  * @return string
  */
 protected static function _memberKey($memberOrType, $ref = null)
 {
     if ($memberOrType instanceof OSM_Objects_Member) {
         if (!empty($ref)) {
             throw new InvalidArgumentException('$ref must be empty');
         }
         return $memberOrType->getType() . $memberOrType->getRef();
     }
     if (empty($ref)) {
         throw new InvalidArgumentException('$ref must not be empty');
     }
     if (!self::isValidMemberType($memberOrType)) {
         throw new OSM_Exception('Invalid member type "' . $memberOrType . '"');
     }
     return $memberOrType . $ref;
 }
Esempio n. 2
0
 /**
  *
  * @param SimpleXMLElement $xmlObj
  * @return OSM_Objects_Member 
  */
 public static function fromXmlObj(SimpleXMLElement $xmlObj)
 {
     $member = new OSM_Objects_Member((string) $xmlObj['type'], (string) $xmlObj['ref'], isset($xmlObj['role']) ? (string) $xmlObj['role'] : null);
     $member->setDirty(false);
     return $member;
 }