You are here

public static function MediaMigrationSourceDatabaseTrait::getFieldConfigTableData in Media Migration 8

Returns the values for the "field_config" database table.

Parameters

bool $with_image_field: Whether the returned data should also contain a record for an image field storage with name "field_image". Defaults to TRUE.

Return value

array[] An array of database table records with values, keyed by the column name.

1 call to MediaMigrationSourceDatabaseTrait::getFieldConfigTableData()
FileEntitySourceFieldInstanceTest::providerSource in tests/src/Kernel/Plugin/migrate/source/d7/FileEntitySourceFieldInstanceTest.php
The data provider.

File

tests/src/Traits/MediaMigrationSourceDatabaseTrait.php, line 20

Class

MediaMigrationSourceDatabaseTrait
Source database table values for Media Migration's tests.

Namespace

Drupal\Tests\media_migration\Traits

Code

public static function getFieldConfigTableData(bool $with_image_field = TRUE) {
  $data = [
    [
      'id' => 2,
      'field_name' => 'body',
      'type' => 'text_with_summary',
      'module' => 'text',
      'active' => 1,
      'storage_type' => 'field_sql_storage',
      'storage_module' => 'field_sql_storage',
      'storage_active' => 1,
      'locked' => 0,
      'data' => serialize([
        'entity_types' => [
          'node',
        ],
        'translatable' => FALSE,
        'settings' => [],
        'storage' => [
          'type' => 'field_sql_storage',
          'settings' => [],
          'module' => 'field_sql_storage',
          'active' => 1,
        ],
        'foreign keys' => [
          'format' => [
            'table' => 'filter_format',
            'columns' => [
              'format' => 'format',
            ],
          ],
        ],
        'indexes' => [
          'format' => [
            'format',
          ],
        ],
      ]),
      'cardinality' => 1,
      'translatable' => 0,
      'deleted' => 0,
    ],
  ];
  if ($with_image_field) {
    $data[] = [
      'id' => 4,
      'field_name' => 'field_image',
      'type' => 'image',
      'module' => 'image',
      'active' => 1,
      'storage_type' => 'field_sql_storage',
      'storage_module' => 'field_sql_storage',
      'storage_active' => 1,
      'locked' => 0,
      'data' => serialize([
        'indexes' => [
          'fid' => [
            'fid',
          ],
        ],
        'settings' => [
          'uri_scheme' => 'public',
          'default_image' => 0,
        ],
        'storage' => [
          'type' => 'field_sql_storage',
          'settings' => [],
          'module' => 'field_sql_storage',
          'active' => 1,
          'details' => [
            'sql' => [
              'FIELD_LOAD_CURRENT' => [
                'field_data_field_image' => [
                  'fid' => 'field_image_fid',
                  'alt' => 'field_image_alt',
                  'title' => 'field_image_title',
                  'width' => 'field_image_width',
                  'height' => 'field_image_height',
                ],
              ],
              'FIELD_LOAD_REVISION' => [
                'field_revision_field_image' => [
                  'fid' => 'field_image_fid',
                  'alt' => 'field_image_alt',
                  'title' => 'field_image_title',
                  'width' => 'field_image_width',
                  'height' => 'field_image_height',
                ],
              ],
            ],
          ],
        ],
        'entity_types' => [],
        'translatable' => FALSE,
        'foreign keys' => [
          'fid' => [
            'table' => 'file_managed',
            'columns' => [
              'fid' => 'fid',
            ],
          ],
        ],
      ]),
      'cardinality' => 1,
      'translatable' => 0,
      'deleted' => 0,
    ];
  }
  return $data;
}