Same name and namespace in other branches
  1. 9 core/modules/field/src/Plugin/migrate/process/d7/FieldBundle.php \Drupal\field\Plugin\migrate\process\d7\FieldBundle::transform()

File

core/modules/field/src/Plugin/migrate/process/d7/FieldBundle.php, line 97

Class

FieldBundle

Namespace

Drupal\field\Plugin\migrate\process\d7

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  [
    $entity_type,
    $bundle,
  ] = $value;
  $lookup_result = NULL;

  // For comment entity types get the destination bundle from the
  // d7_comment_type migration, if it exists.
  if ($entity_type === 'comment' && $bundle != 'comment_forum') {
    $lookup_result = $row
      ->get('@_comment_type');

    // Legacy generated migrations will not have the destination property
    // '_comment_type'.
    if (!$row
      ->hasDestinationProperty('_comment_type')) {
      $value = str_replace('comment_node_', '', $bundle);
      $migration = 'd7_comment_type';
      $lookup_result = $this->migrateLookup
        ->lookup($migration, [
        $value,
      ]);
      $lookup_result = empty($lookup_result) ? NULL : reset($lookup_result[0]);
    }
  }
  return $lookup_result ? $lookup_result : $bundle;
}