You are here

public function CommerceReferenceRevision::transform in Commerce Migrate 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/migrate/process/CommerceReferenceRevision.php \Drupal\commerce_migrate\Plugin\migrate\process\CommerceReferenceRevision::transform()
  2. 3.1.x src/Plugin/migrate/process/CommerceReferenceRevision.php \Drupal\commerce_migrate\Plugin\migrate\process\CommerceReferenceRevision::transform()

Throws

\Drupal\migrate\MigrateSkipProcessException

\Drupal\migrate\MigrateException

Overrides MigrationLookup::transform

File

src/Plugin/migrate/process/CommerceReferenceRevision.php, line 21

Class

CommerceReferenceRevision
Migrate reference fields.

Namespace

Drupal\commerce_migrate\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  if (!is_array($value)) {

    // Convert the value into a non-scalar value, so the parent method will
    // return our values properly.
    $value = [
      $value,
    ];
  }
  $ids = parent::transform($value, $migrate_executable, $row, $destination_property);
  $target_id = $ids[0];
  $revision_id = $ids[1];
  return [
    'target_id' => $target_id,
    'target_revision_id' => $revision_id,
  ];
}