You are here

public function MigrateDestinationLineItem::import in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

Import a single node.

Parameters

$node: Node 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 (nid only in this case) of the node that was saved if successful. FALSE on failure.

Overrides MigrateDestination::import

File

merci_migrate/merci_line_item.inc, line 126

Class

MigrateDestinationLineItem

Code

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

  // Updating previously-migrated content?
  $migration = Migration::currentMigration();
  if (!isset($object->type)) {

    // Default the type to our designated destination bundle (by doing this
    // conditionally, we permit some flexibility in terms of implementing
    // migrations which can affect more than one type).
    $object->type = $this->bundle;
  }

  // Invoke migration prepare handlers
  $this
    ->prepare($object, $row);

  // Validate field data prior to saving.
  MigrateDestinationEntity::fieldAttachValidate('merci_line_item', $object);
  migrate_instrument_start('merci_line_item_save');
  entity_save('merci_line_item', $object);
  migrate_instrument_stop('merci_line_item_save');
  if (isset($object->line_item_id)) {
    $this->numCreated++;
    $return = array(
      $object->line_item_id,
    );
  }
  else {
    $return = FALSE;
  }
  $this
    ->complete($object, $row);
  return $return;
}