You are here

protected function SqlIdMapTest::getFieldSchema in Drupal 9

Gets the field schema.

Parameters

array $id_definition: An array defining the field, with a key 'type'.

Return value

array A field schema depending on value of key 'type'. An empty array is returned if 'type' is not defined.

Throws

\Drupal\migrate\MigrateException

Overrides TestSqlIdMap::getFieldSchema

File

core/modules/migrate/tests/src/Kernel/Plugin/id_map/SqlTest.php, line 182

Class

SqlIdMapTest
Defines a test SQL ID map for use in tests.

Namespace

Drupal\Tests\migrate\Kernel\Plugin\id_map

Code

protected function getFieldSchema(array $id_definition) {
  if (!isset($id_definition['type'])) {
    return [];
  }
  switch ($id_definition['type']) {
    case 'integer':
      return [
        'type' => 'int',
        'not null' => TRUE,
      ];
    case 'string':
      return [
        'type' => 'varchar',
        'length' => 65536,
        'not null' => FALSE,
      ];
    default:
      throw new MigrateException($id_definition['type'] . ' not supported');
  }
}