You are here

public function TextField::processCckFieldValues in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/text/src/Plugin/migrate/cckfield/TextField.php \Drupal\text\Plugin\migrate\cckfield\TextField::processCckFieldValues()

Apply any custom processing to the cck bundle migrations.

Parameters

\Drupal\migrate\Entity\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 CckFieldValues::fieldData().

Overrides MigrateCckFieldInterface::processCckFieldValues

File

core/modules/text/src/Plugin/migrate/cckfield/TextField.php, line 44
Contains \Drupal\text\Plugin\migrate\cckfield\TextField.

Class

TextField
Plugin annotation @MigrateCckField( id = "text" )

Namespace

Drupal\text\Plugin\migrate\cckfield

Code

public function processCckFieldValues(MigrationInterface $migration, $field_name, $field_info) {
  if ($field_info['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',
          'migration' => [
            'd6_filter_format',
            'd7_filter_format',
          ],
          'source' => 'format',
        ],
      ],
    ];
  }
  $process = array(
    'plugin' => 'iterator',
    'source' => $field_name,
    'process' => $process,
  );
  $migration
    ->setProcessOfProperty($field_name, $process);
}