You are here

public function MigrateDestinationUserRelationships::import in Migrate Extras 7.2

Same name and namespace in other branches
  1. 6.2 user_relationships.inc \MigrateDestinationUserRelationships::import()

Import a single membership.

Parameters

$entity: Object object to build. Prefilled with any fields mapped in the Migration.

$row: Raw source data object - passed through to prepare/complete handlers.

Return value

array Array of key fields of the object that was saved if successful. FALSE on failure.

Overrides MigrateDestination::import

File

./user_relationships.inc, line 72
Import User Relationships.

Class

MigrateDestinationUserRelationships
Destination class implementing migration into user_relationships table.

Code

public function import(stdClass $entity, stdClass $row) {

  // Normalize to unix timestamps.
  foreach (array(
    'created_at',
    'updated_at',
  ) as $property) {
    if (isset($entity->{$property})) {
      $entity->{$property} = Migration::timestamp($entity->{$property});
    }
  }
  $entity->rtid = $this->typeID;
  $op = isset($entity->op) ? $entity->op : 'approve';
  if ($saved = user_relationships_save_relationship($entity, $op)) {
    return array(
      $saved->rid,
    );
  }
}