function BlockPluginId::transform
Same name in other branches
- 9 core/modules/block/src/Plugin/migrate/process/BlockPluginId.php \Drupal\block\Plugin\migrate\process\BlockPluginId::transform()
- 8.9.x core/modules/block/src/Plugin/migrate/process/BlockPluginId.php \Drupal\block\Plugin\migrate\process\BlockPluginId::transform()
- 11.x core/modules/block/src/Plugin/migrate/process/BlockPluginId.php \Drupal\block\Plugin\migrate\process\BlockPluginId::transform()
Set the block plugin id.
Overrides ProcessPluginBase::transform
File
-
core/
modules/ block/ src/ Plugin/ migrate/ process/ BlockPluginId.php, line 72
Class
Namespace
Drupal\block\Plugin\migrate\processCode
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (is_array($value)) {
[
$module,
$delta,
] = $value;
switch ($module) {
case 'aggregator':
[
$type,
] = explode('-', $delta);
if ($type == 'feed') {
return 'aggregator_feed_block';
}
break;
case 'menu':
return "system_menu_block:{$delta}";
case 'block':
if ($this->blockContentStorage) {
$block_id = $row->getDestinationProperty('_block_module_plugin_id');
// Legacy generated migrations will not have the destination
// property '_block_module_plugin_id'.
if (!$block_id) {
$lookup_result = $this->migrateLookup
->lookup([
'd6_custom_block',
'd7_custom_block',
], [
$delta,
]);
if ($lookup_result) {
$block_id = $lookup_result[0]['id'];
}
}
if ($block_id) {
return 'block_content:' . $this->blockContentStorage
->load($block_id)
->uuid();
}
}
break;
default:
break;
}
}
else {
return $value;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.