You are here

public function FieldBundle::transform in Drupal 10

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()

Performs the associated process.

Parameters

mixed $value: The value to be transformed.

\Drupal\migrate\MigrateExecutableInterface $migrate_executable: The migration in which this process is being executed.

\Drupal\migrate\Row $row: The row from the source to process. Normally, just transforming the value is adequate but very rarely you might need to change two columns at the same time or something like that.

string $destination_property: The destination property currently worked on. This is only used together with the $row above.

Return value

mixed The newly transformed value.

Overrides ProcessPluginBase::transform

File

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

Class

FieldBundle
Determines the bundle for a field.

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') {
    $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;
}