You are here

public function TextField::defineValueProcessPipeline in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/text/src/Plugin/migrate/field/d6/TextField.php \Drupal\text\Plugin\migrate\field\d6\TextField::defineValueProcessPipeline()

Apply any custom processing to the field bundle migrations.

Parameters

\Drupal\migrate\Plugin\MigrationInterface $migration: The migration entity.

string $field_name: The field name we're processing the value for.

array $data: The array of field data from FieldValues::fieldData().

Overrides FieldPluginBase::defineValueProcessPipeline

File

core/modules/text/src/Plugin/migrate/field/d6/TextField.php, line 47

Class

TextField
Plugin annotation @MigrateField( id = "d6_text", type_map = { "text" = "text", "text_long" = "text_long", "text_with_summary" = "text_with_summary" }, core = {6}, source_module = "text", destination_module = "text", )

Namespace

Drupal\text\Plugin\migrate\field\d6

Code

public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $field_info) {
  $widget_type = isset($field_info['widget_type']) ? $field_info['widget_type'] : $field_info['widget']['type'];
  if ($widget_type == 'optionwidgets_onoff') {
    $process = [
      'value' => [
        'plugin' => 'static_map',
        'source' => 'value',
        'default_value' => 0,
      ],
    ];
    $checked_value = explode("\n", $field_info['global_settings']['allowed_values'])[1];
    if (strpos($checked_value, '|') !== FALSE) {
      $checked_value = substr($checked_value, 0, strpos($checked_value, '|'));
    }
    $process['value']['map'][$checked_value] = 1;
  }
  else {

    // See \Drupal\migrate_drupal\Plugin\migrate\source\d6\User::baseFields(),
    // signature_format for an example of the YAML that represents this
    // process array.
    $process = [
      'value' => 'value',
      'format' => [
        [
          'plugin' => 'static_map',
          'bypass' => TRUE,
          'source' => 'format',
          'map' => [
            0 => NULL,
          ],
        ],
        [
          'plugin' => 'skip_on_empty',
          'method' => 'process',
        ],
        [
          'plugin' => 'migration_lookup',
          'migration' => [
            'd6_filter_format',
            'd7_filter_format',
          ],
          'source' => 'format',
        ],
      ],
    ];
  }
  $process = [
    'plugin' => 'sub_process',
    'source' => $field_name,
    'process' => $process,
  ];
  $migration
    ->setProcessOfProperty($field_name, $process);
}