Dumplie\Metadata\Infrastructure\Doctrine\Dbal\TypeRegistry::map PHP Method

map() public method

public map ( string $schema, Doctrine\DBAL\Schema\Table $table, string $name, Dumplie\Metadata\Schema\FieldDefinition $definition )
$schema string
$table Doctrine\DBAL\Schema\Table
$name string
$definition Dumplie\Metadata\Schema\FieldDefinition
    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());
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param DBALSchema $schema
  * @param string     $schemaName
  * @param TypeSchema $type
  *
  * @throws DoctrineStorageException
  */
 private function createTable(DBALSchema $schema, string $schemaName, TypeSchema $type)
 {
     $table = $schema->createTable($this->tableName($schemaName, $type->name()));
     $table->addColumn('id', 'guid');
     $table->setPrimaryKey(['id']);
     foreach ($type->getDefinitions(['id']) as $field => $definition) {
         $this->typeRegistry->map($schemaName, $table, $field, $definition);
     }
 }