Beispiel #1
0
 public function constructFromSimpleXMLElement(SimpleXMLElement $attribute)
 {
     $this->logicalName = strtolower((string) $attribute->LogicalName);
     $this->label = (string) $attribute->DisplayName->UserLocalizedLabel->Label;
     $this->description = (string) $attribute->Description->UserLocalizedLabel->Label;
     $this->format = (string) $attribute->Format;
     $this->maxLength = (int) $attribute->MaxLength;
     $this->imeMode = (string) $attribute->ImeMode;
     $this->isCustom = (string) $attribute->IsCustomAttribute === 'true';
     $this->isPrimaryId = (string) $attribute->IsPrimaryId === 'true';
     $this->isPrimaryName = (string) $attribute->IsPrimaryName === 'true';
     $this->type = (string) $attribute->AttributeType;
     /* Determine the Type of the Attribute */
     $attributeList = $attribute->attributes();
     $attributeType = AbstractClient::stripNS((string) $attributeList['type']);
     /* Handle the special case of Lookup types */
     $this->isLookup = $attributeType == 'LookupAttributeMetadata';
     /* If it's a Lookup, check what Targets are allowed */
     if ($this->isLookup) {
         $this->lookupTypes = array();
         /* Add lookup types to Properties, search for target entities */
         foreach ($attribute->Targets->string as $target) {
             array_push($this->lookupTypes, (string) $target);
         }
     } else {
         $this->lookupTypes = null;
     }
     $this->isValidForCreate = (string) $attribute->IsValidForCreate === 'true';
     $this->isValidForUpdate = (string) $attribute->IsValidForUpdate === 'true';
     $this->isValidForRead = (string) $attribute->IsValidForRead === 'true';
     /* Check if this field is mandatory */
     $this->requiredLevel = (string) $attribute->RequiredLevel->Value;
     $this->attributeOf = (string) $attribute->AttributeOf;
     $this->optionSet = (string) $attribute->OptionSet->Name;
     /* If this is an OptionSet, determine the OptionSet details */
     if (!empty($attribute->OptionSet) && !empty($attribute->OptionSet->Name)) {
         $this->optionSet = new OptionSet($attribute->OptionSet);
     } else {
         /* Not an OptionSet */
         $this->optionSet = null;
     }
 }