예제 #1
0
 /**
  * @param string $kind
  *
  * @return Field
  */
 private static function createField($kind)
 {
     if (!isset(self::$fields[$kind])) {
         switch ($kind) {
             case DynamicFieldKind::STRING_VAL:
                 $type = StringType::create();
                 break;
             case DynamicFieldKind::TEXT_VAL:
                 $type = TextType::create();
                 break;
             case DynamicFieldKind::INT_VAL:
                 $type = IntType::create();
                 break;
             case DynamicFieldKind::BOOL_VAL:
                 $type = BooleanType::create();
                 break;
             case DynamicFieldKind::FLOAT_VAL:
                 $type = FloatType::create();
                 break;
             case DynamicFieldKind::DATE_VAL:
                 $type = DateType::create();
                 break;
             default:
                 throw new InvalidArgumentException(sprintf('DynamicField "%s" is not a valid type.', $kind));
         }
         self::$fields[$kind] = new Field($kind, $type, FieldRule::A_SINGLE_VALUE(), true);
     }
     return self::$fields[$kind];
 }
예제 #2
0
파일: Field.php 프로젝트: gdbots/pbj-php
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     return ['name' => $this->name, 'type' => $this->type->getTypeValue(), 'rule' => $this->rule->getName(), 'required' => $this->required, 'min_length' => $this->minLength, 'max_length' => $this->maxLength, 'pattern' => $this->pattern, 'format' => $this->format->getValue(), 'min' => $this->min, 'max' => $this->max, 'precision' => $this->precision, 'scale' => $this->scale, 'default' => $this->getDefault(), 'use_type_default' => $this->useTypeDefault, 'class_name' => $this->className, 'any_of_class_names' => $this->anyOfClassNames, 'has_assertion' => null !== $this->assertion, 'overridable' => $this->overridable];
 }
예제 #3
0
 /**
  * @return Field
  */
 public function build()
 {
     if (null === $this->rule) {
         $this->rule = FieldRule::A_SINGLE_VALUE();
     }
     return new Field($this->name, $this->type, $this->rule, $this->required, $this->minLength, $this->maxLength, $this->pattern, $this->format, $this->min, $this->max, $this->precision, $this->scale, $this->default, $this->useTypeDefault, $this->className, $this->anyOfClassNames, $this->assertion, $this->overridable);
 }