function FieldFile::transform
Same name in other branches
- 9 core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php \Drupal\file\Plugin\migrate\process\d6\FieldFile::transform()
- 10 core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php \Drupal\file\Plugin\migrate\process\d6\FieldFile::transform()
- 11.x core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php \Drupal\file\Plugin\migrate\process\d6\FieldFile::transform()
Overrides ProcessPluginBase::transform
File
-
core/
modules/ file/ src/ Plugin/ migrate/ process/ d6/ FieldFile.php, line 87
Class
- FieldFile
- Plugin annotation @MigrateProcessPlugin( id = "d6_field_file" )
Namespace
Drupal\file\Plugin\migrate\process\d6Code
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$options = unserialize($value['data']);
// 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
// fatals), so return an empty item instead.
// This BC layer is included because if the plugin constructor was called
// in the legacy way with a migration_lookup process plugin, it may have
// been preconfigured with a different migration to look up against. While
// this is unlikely, for maximum BC we will continue to use the plugin to do
// the lookup if it is provided, and support for this will be removed in
// Drupal 9.
if ($this->migrationPlugin) {
$fid = $this->migrationPlugin
->transform($value['fid'], $migrate_executable, $row, $destination_property);
}
else {
$lookup_result = $this->migrateLookup
->lookup('d6_file', [
$value['fid'],
]);
if ($lookup_result) {
$fid = $lookup_result[0]['fid'];
}
}
if (!empty($fid)) {
return [
'target_id' => $fid,
'display' => $value['list'],
'description' => isset($options['description']) ? $options['description'] : '',
'alt' => isset($options['alt']) ? $options['alt'] : '',
'title' => isset($options['title']) ? $options['title'] : '',
];
}
else {
return [];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.