public function ProductVariationFile::transform in Commerce Migrate 8.2
Same name and namespace in other branches
- 3.1.x modules/csv_example/src/Plugin/migrate/process/ProductVariationFile.php \Drupal\commerce_migrate_csv_example\Plugin\migrate\process\ProductVariationFile::transform()
- 3.0.x modules/csv_example/src/Plugin/migrate/process/ProductVariationFile.php \Drupal\commerce_migrate_csv_example\Plugin\migrate\process\ProductVariationFile::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
string|array The newly transformed value.
Overrides ProcessPluginBase::transform
File
- modules/
csv_example/ src/ Plugin/ migrate/ process/ ProductVariationFile.php, line 98
Class
- ProductVariationFile
- Get the fid for the provided filename.
Namespace
Drupal\commerce_migrate_csv_example\Plugin\migrate\processCode
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
// Try to look up the ID of the migrated file. If one cannot be found, it
// means the file referenced by the current field item did not migrate for
// some reason -- file migration is notoriously brittle -- and we do NOT
// want to send invalid file references into the field system (it causes
// fatal errors), so return an empty item instead.
if ($fid = $this->migrationPlugin
->transform($value, $migrate_executable, $row, $destination_property)) {
return [
'target_id' => $fid,
'description' => '',
'alt' => '',
'title' => '',
];
}
else {
return [];
}
}