예제 #1
0
 $field->setDisplayName($display_name[$i]);
 $field->setDataType($data_type[$i]);
 if (@$required[$i] == "true") {
     $field->setRequired(TRUE);
 } else {
     $field->setRequired(FALSE);
 }
 $field->setMin($min[$i]);
 $field->setMax($max[$i]);
 if (@$unique[$i] == "true") {
     $field->setUnique(TRUE);
 } else {
     $field->setUnique(FALSE);
 }
 $field->setExample($example[$i]);
 $field->setForeignKey($foreign_key[$i]);
 $field->setForeignValue($foreign_value[$i]);
 switch ($data_type[$i]) {
     case "string":
         $field->setRegexp($pattern[$i]);
         break;
     case "decimal":
         $field->setPrecision($pattern[$i]);
         break;
     case "enum":
         $optionsString = $pattern[$i];
         $enumOptions = explode(",", $optionsString);
         $field->setEnumOptions($enumOptions);
         break;
     case "text":
     case "binary":
 private static function parseJoinBlueprint($xml)
 {
     $blueprint = new JoinBlueprint((string) $xml['key']);
     // iterate through blueprints fields, defining them in blueprint object
     foreach ($xml->field as $f) {
         $field = new EntityField((string) $f['key']);
         // common
         $field->setDisplayName((string) $f->displayName);
         $field->setDataType((string) $f->dataType);
         $field->setMimeType((string) $f->mimeType);
         $field->setPrecision((string) $f->precision);
         $encType = (string) $f->encType;
         if (!empty($encType)) {
             $field->setEncType((string) $f->encType);
         }
         $required = (string) $f->required;
         if (strtolower($required) == "true") {
             $field->setRequired(true);
         } else {
             $field->setRequired(false);
         }
         //$field->setMin((string) $f->minimum);
         $minimum = (string) $f->minimum;
         if (!empty($minimum)) {
             $field->setMin($minimum);
         }
         //$field->setMax((string) $f->maximum);
         $maximum = (string) $f->maximum;
         if (!empty($maximum)) {
             $field->setMax($maximum);
         }
         $field->setRegexp((string) $f->regexp);
         $field->setExample((string) $f->example);
         $unique = (string) $f->unique;
         if (strtolower($unique) == "true") {
             $field->setUnique(true);
         } else {
             $field->setUnique(false);
         }
         $field->setForeignKey((string) $f->foreignKey);
         $field->setForeignValue((string) $f->foreignValue);
         if ($field->getDataType() == "enum") {
             $enumOptions = array();
             foreach ($f->enumOptions->option as $option) {
                 $enumOptions[] = (string) $option;
             }
             $field->setEnumOptions($enumOptions);
         }
         $blueprint->add($field);
     }
     return $blueprint;
 }