*
* Examples:
*
- * Consider a node migration, where you want to maintain authorship. If you have
- * migrated the user accounts in a migration named "users", you would specify
- * the following:
- *
+ * Consider a node migration, where you want to maintain authorship. Let's
+ * assume that users are previously migrated in a migration named 'users'. The
+ * 'users' migration saved the mapping between the source and destination IDs in
+ * a map table. The node migration example below maps the node 'uid' property so
+ * that we first take the source 'author' value and then do a lookup for the
+ * corresponding Drupal user ID from the map table.
* @code
* process:
* uid:
* source: author
* @endcode
*
- * This takes the value of the author property in the source data, and looks it
- * up in the map table associated with the users migration, returning the
- * resulting user ID and assigning it to the destination uid property.
- *
* The value of 'migration' can be a list of migration IDs. When using multiple
* migrations it is possible each use different source identifiers. In this
* case one can use source_ids which is an array keyed by the migration IDs
- * and the value is a list of source properties.
- *
+ * and the value is a list of source properties. See example below.
* @code
* process:
* uid:
* map it will create a stub entity for the relationship to use. This stub is
* generated by the migration provided. In the case of multiple migrations the
* first value of the migration list will be used, but you can select the
- * migration you wish to use by using the stub_id configuration key:
- *
+ * migration you wish to use by using the stub_id configuration key. The example
+ * below uses 'members' migration to create stub entities.
* @code
* process:
* uid:
* stub_id: members
* @endcode
*
- * In the above example, the value of stub_id selects the members migration to
- * create any stub entities.
- *
* To prevent the creation of a stub entity when no relationship is found in the
- * migration map, use no_stub:
- *
+ * migration map, 'no_stub' configuration can be used as shown below.
* @code
* process:
* uid:
if (!is_array($migration_ids)) {
$migration_ids = [$migration_ids];
}
- if (!is_array($value)) {
- $value = [$value];
- }
- $this->skipOnEmpty($value);
$self = FALSE;
/** @var \Drupal\migrate\Plugin\MigrationInterface[] $migrations */
$destination_ids = NULL;
}
if (isset($this->configuration['source_ids'][$migration_id])) {
$configuration = ['source' => $this->configuration['source_ids'][$migration_id]];
- $source_id_values[$migration_id] = $this->processPluginManager
+ $value = $this->processPluginManager
->createInstance('get', $configuration, $this->migration)
->transform(NULL, $migrate_executable, $row, $destination_property);
}
- else {
- $source_id_values[$migration_id] = $value;
+ if (!is_array($value)) {
+ $value = [$value];
}
+ $this->skipOnEmpty($value);
+ $source_id_values[$migration_id] = $value;
// Break out of the loop as soon as a destination ID is found.
if ($destination_ids = $migration->getIdMap()->lookupDestinationId($source_id_values[$migration_id])) {
break;