Ejemplo n.º 1
0
 /**
  * @param string          $schema
  * @param Table           $table
  * @param string          $name
  * @param FieldDefinition $definition
  */
 public function map(string $schema, Table $table, string $name, FieldDefinition $definition)
 {
     $table->addColumn($name, 'float', ['notnull' => !$definition->isNullable(), 'default' => $definition->defaultValue(), 'unique' => $definition->options()['unique'] ?? false]);
     if ($definition->options()['index'] ?? false) {
         $table->addIndex([$name]);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param string          $schema
  * @param Table           $table
  * @param string          $name
  * @param FieldDefinition $definition
  *
  * @throws DoctrineStorageException
  */
 public function map(string $schema, Table $table, string $name, FieldDefinition $definition)
 {
     foreach ($this->mapping as $mapping) {
         if ($mapping->maps($definition->type())) {
             $mapping->map($schema, $table, $name, $definition);
             return;
         }
     }
     throw DoctrineStorageException::unableToMapType($definition->type());
 }
Ejemplo n.º 3
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  * @param FieldDefinition $definition
  */
 protected function buildTextType(FormBuilderInterface $builder, array $options, string $fieldName, FieldDefinition $definition)
 {
     $typeOptions = $options['type_options'];
     $typeForms = $options['type_forms'];
     $isRequired = !$definition->isNullable();
     $options = ['required' => $isRequired];
     if ($isRequired) {
         $options['constraints'] = [new NotBlank()];
     }
     $builder->add($fieldName, array_key_exists($fieldName, $typeForms) ? $typeForms[$fieldName] : TextType::class, array_key_exists($fieldName, $typeOptions) ? array_merge($options, $typeOptions[$fieldName]) : $options);
 }
Ejemplo n.º 4
0
 public static function valueDoesNotMatchType(FieldDefinition $type, $value) : InvalidValueException
 {
     return new self(sprintf("Value \"%s\" does not match type \"%s\"", (string) new StringConverter($value), $type->name()));
 }