function FieldBundle::transform
Same name in other branches
- 9 core/modules/field/src/Plugin/migrate/process/d7/FieldBundle.php \Drupal\field\Plugin\migrate\process\d7\FieldBundle::transform()
- 10 core/modules/field/src/Plugin/migrate/process/d7/FieldBundle.php \Drupal\field\Plugin\migrate\process\d7\FieldBundle::transform()
Overrides ProcessPluginBase::transform
File
-
core/
modules/ field/ src/ Plugin/ migrate/ process/ d7/ FieldBundle.php, line 97
Class
- FieldBundle
- Determines the bundle for a field.
Namespace
Drupal\field\Plugin\migrate\process\d7Code
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.