Quantcast
Channel: Drupal
Viewing all articles
Browse latest Browse all 81

Relation Migrate integration and *reference upgrade path

$
0
0

There was my patch committed to Relation module (which is great - if you have not tried it yet definitely do) today, that adds Migrate support to Relation and uses it to provide upgrade path from Term/User/Node/Entity reference fields to Relation. I hope that this feature will be useful to a lot of people. In order to use new functionality you'd need to enable Relation migrate, which comes together with Relation.

Migrate integration

Module implements class MigrateDestinationRelation, which is a destination plugin for Migrate. You can use this class in your custom migrate scripts in a very similar way as you'd use MigrateDestinationNode, which is most likely used when migrating nodes. The only difference will be in mapping, which should be done in prepare() or prepareRow(). This is required because of the complexity of relation_endpoint field, which requires a lot of information in order to properly build a relation. Here is an example of typical mapping definition:

public function prepare(stdClass $relation, stdClass $source_row) {
  $relation->endpoints[LANGUAGE_NONE] = array(
    array('entity_type' => $source_row->source_type, 'entity_id' => $source_row->source_id),
    array('entity_type' => $source_row->destination_type, 'entity_id' => $source_row->destination_id),
  );
}

This example is taken from actual implementation of *reference upgrade path in Relation migrate.


Viewing all articles
Browse latest Browse all 81

Trending Articles