You are here

protected function TestSmartSqlIdMap::getFieldSchema in Smart SQL ID Map 1.1.x

Same name and namespace in other branches
  1. 1.0.x tests/src/Unit/TestSmartSqlIdMap.php \Drupal\Tests\smart_sql_idmap\Unit\TestSmartSqlIdMap::getFieldSchema()

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 Sql::getFieldSchema

File

tests/src/Unit/TestSmartSqlIdMap.php, line 72

Class

TestSmartSqlIdMap
A Smart SQL ID map-based plugin that can be used for testing SmartSql.

Namespace

Drupal\Tests\smart_sql_idmap\Unit

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' => 255,
        'not null' => FALSE,
      ];
    default:
      throw new MigrateException($id_definition['type'] . ' not supported');
  }
}