Exemple #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);
     }
 }
 public function setUp()
 {
     $this->connection = DriverManager::getConnection(json_decode(DUMPLIE_TEST_DB_CONNECTION, true));
     if ($this->connection->getSchemaManager()->tablesExist('metadata_test_bar')) {
         $this->connection->getSchemaManager()->dropTable('metadata_test_bar');
     }
     if ($this->connection->getSchemaManager()->tablesExist('metadata_test_foo')) {
         $this->connection->getSchemaManager()->dropTable('metadata_test_foo');
     }
     $foo = new TypeSchema('foo', ['id' => new TextField(), 'text' => new TextField(null, false, ['index' => true])]);
     $bar = new TypeSchema('bar', ['id' => new TextField(), 'link' => new AssociationField('test', $foo)]);
     $this->schema = new Schema('test');
     $this->schema->add($foo);
     $this->schema->add($bar);
     $this->storage = new DoctrineStorage($this->connection, TypeRegistry::withDefaultTypes());
 }
Exemple #3
0
 /**
  * @return Storage
  */
 public function createStorage() : Storage
 {
     return new DoctrineStorage(self::createConnection(), TypeRegistry::withDefaultTypes());
 }