You are here

public function MigrateDestinationRestrictions::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_restrictions.inc, line 147
Support for node destinations.

Class

MigrateDestinationRestrictions
Destination class implementing migration into nodes.

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_restrictions', $object);
  migrate_instrument_start('merci_restrictions__save');
  entity_save('merci_restrictions', $object);
  migrate_instrument_stop('merci_restrictions_save');
  if (isset($object->id)) {
    $this->numCreated++;
    $return = array(
      $object->id,
    );
  }
  else {
    $return = FALSE;
  }
  $this
    ->complete($object, $row);
  return $return;
}