You are here

public static function MediaMigrationSourceDatabaseTrait::getFieldConfigInstanceTableData in Media Migration 8

Returns the values for the "field_config_instance" database table.

Parameters

bool $with_node_article_image_field: Whether the returned data should also contain a record for an image field instance "field_image" used on node article. Defaults to FALSE.

bool $node_article_image_alt_allowed: Whether the returned image field instance "field_image" of article nodes (if any) should allow editing the "alt" property of the images. Defaults to FALSE.

bool $node_article_image_title_allowed: Whether the returned image field instance "field_image" of article nodes (if any) should allow editing the "title" property of the images. Defaults to FALSE.

bool $media_image_alt_required: Whether image media on the source is configured to require the "alt" property for images. Defaults to FALSE.

bool $media_image_title_required: Whether image media on the source is configured to require the "title" property for images. Defaults to FALSE.

Return value

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

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

File

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

Class

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

Namespace

Drupal\Tests\media_migration\Traits

Code

public static function getFieldConfigInstanceTableData(bool $with_node_article_image_field = FALSE, bool $node_article_image_alt_allowed = FALSE, bool $node_article_image_title_allowed = FALSE, bool $media_image_alt_required = FALSE, bool $media_image_title_required = FALSE) {
  $data = [
    [
      'id' => 7,
      'field_id' => 5,
      'field_name' => 'field_file_image_alt_text',
      'entity_type' => 'file',
      'bundle' => 'image',
      'data' => serialize([
        'default_value' => NULL,
        'description' => 'Help text for alt field',
        'display' => [
          'default' => [
            'label' => 'above',
            'settings' => [],
            'type' => 'hidden',
            'weight' => 0,
          ],
          'full' => [
            'label' => 'above',
            'settings' => [],
            'type' => 'hidden',
            'weight' => 0,
          ],
          'preview' => [
            'label' => 'above',
            'settings' => [],
            'type' => 'hidden',
            'weight' => 0,
          ],
          'teaser' => [
            'label' => 'above',
            'settings' => [],
            'type' => 'hidden',
            'weight' => 0,
          ],
        ],
        'label' => 'Alt Text',
        'required' => (int) $media_image_alt_required,
        'settings' => [
          'text_processing' => '0',
          'user_register_form' => FALSE,
          'wysiwyg_override' => 1,
        ],
        'widget' => [
          'active' => 1,
          'module' => 'text',
          'settings' => [
            'size' => '60',
          ],
          'type' => 'text_textfield',
          'weight' => '-4',
        ],
      ]),
      'deleted' => 0,
    ],
    [
      'id' => 8,
      'field_id' => 6,
      'field_name' => 'field_file_image_title_text',
      'entity_type' => 'file',
      'bundle' => 'image',
      'data' => serialize([
        'default_value' => NULL,
        'description' => 'Help text for title field',
        'display' => [
          'default' => [
            'label' => 'above',
            'settings' => [],
            'type' => 'hidden',
            'weight' => 1,
          ],
          'full' => [
            'label' => 'above',
            'settings' => [],
            'type' => 'hidden',
            'weight' => 0,
          ],
          'preview' => [
            'label' => 'above',
            'settings' => [],
            'type' => 'hidden',
            'weight' => 0,
          ],
          'teaser' => [
            'label' => 'above',
            'settings' => [],
            'type' => 'hidden',
            'weight' => 0,
          ],
        ],
        'label' => 'Title Text',
        'required' => (int) $media_image_title_required,
        'settings' => [
          'text_processing' => '0',
          'user_register_form' => FALSE,
          'wysiwyg_override' => 1,
        ],
        'widget' => [
          'active' => 1,
          'module' => 'text',
          'settings' => [
            'size' => '60',
          ],
          'type' => 'text_textfield',
          'weight' => '-3',
        ],
      ]),
      'deleted' => 0,
    ],
  ];
  if ($with_node_article_image_field) {
    $data[] = [
      'id' => 6,
      'field_id' => 4,
      'field_name' => 'field_image',
      'entity_type' => 'node',
      'bundle' => 'article',
      'data' => serialize([
        'label' => 'Image',
        'description' => 'Upload an image to go with this article.',
        'required' => 0,
        'settings' => [
          'file_directory' => 'field/image',
          'file_extensions' => 'png gif jpg jpeg',
          'max_filesize' => '2 MB',
          'max_resolution' => '',
          'min_resolution' => '',
          'alt_field' => (int) $node_article_image_alt_allowed,
          'title_field' => (int) $node_article_image_title_allowed,
          'default_image' => 0,
          'user_register_form' => FALSE,
        ],
        'widget' => [
          'weight' => '-1',
          'type' => 'image_image',
          'module' => 'image',
          'active' => 1,
          'settings' => [
            'progress_indicator' => 'throbber',
            'preview_image_style' => 'thumbnail',
          ],
        ],
        'display' => [
          'default' => [
            'label' => 'above',
            'type' => 'image',
            'weight' => '-1',
            'settings' => [
              'image_style' => 'large',
              'image_link' => '',
            ],
            'module' => 'image',
          ],
          'teaser' => [
            'label' => 'hidden',
            'type' => 'image',
            'settings' => [
              'image_style' => 'medium',
              'image_link' => 'content',
            ],
            'weight' => -1,
            'module' => 'image',
          ],
        ],
      ]),
      'deleted' => 0,
    ];
  }
  return $data;
}