Here is how I could achieve a dynamic destination bundle based on a condition:
id: dynamic_bundle_migration_example
label: 'Dynamic Bundle Migration Example'
description: 'Demonstrates how to define a dynamic bundle based on an arbitrary condition.'
source:
plugin: d8_entity
entity_type: paragraph
bundle: full_text
key: migration_source_db
process:
iframe_regex:
plugin: default_value
default_value: '/<iframe/'
iframe_found:
plugin: callback
callable: 'preg_match'
unpack_source: true
source:
- '@iframe_regex'
- 'field_text/0/value'
type:
plugin: static_map
source: '@iframe_found'
map:
'1': 'embed'
'0': 'wysiwyg'
default_value: 'wysiwyg'
bypass: true
field_text:
plugin: sub_process
source: field_text
process:
value: value
format:
plugin: default_value
default_value: 'rich_text_full'
destination:
plugin: 'entity_reference_revisions:paragraph'
Roughly speaking, you don't need to set the default_bundle property on your destination configuration if you provide the bundle information inside your process configuration.
The above migration migrates paragraph entities of either bundle embed or wysiwyg.
It does this by setting the type destination property to a dynamic value. It's simply checking for whether field_text has an iframe on it's value. If so, type is embed, otherwise wysiwyg.
--
PS: You need to check what is the bundle key for the entity type being migrated. Not all entity types' bundles are called type.
Taxonomy Term entities, for example, have its bundle key called vid.
Here is a one-liner for checking your destination entity type's bundle key using Drush:
drush ev "print \Drupal::entityTypeManager()->getDefinition('taxonomy_term')->getKey('bundle');"