You are here

public function MigrateFieldsEntityHandler::complete in Migrate 7.2

File

plugins/destinations/fields.inc, line 87
Support for processing entity fields

Class

MigrateFieldsEntityHandler
@file Support for processing entity fields

Code

public function complete($entity, stdClass $row) {
  migrate_instrument_start('MigrateDestinationEntity->completeFields');

  // Look for Field API fields attached to this destination
  // and handle appropriately.
  $migration = Migration::currentMigration();
  $destination = $migration
    ->getDestination();
  $entity_type = $destination
    ->getEntityType();
  $bundle = $destination
    ->getBundle();
  $instances = field_info_instances($entity_type, $bundle);
  foreach ($instances as $machine_name => $instance) {
    if (property_exists($entity, $machine_name)) {

      // Normalize to an array.
      if (!is_array($entity->{$machine_name})) {
        $entity->{$machine_name} = array(
          $entity->{$machine_name},
        );
      }
      $field_info = field_info_field($machine_name);
      migrate_field_handler_invoke_all($entity, $field_info, $instance, $entity->{$machine_name}, 'complete');
    }
  }
  migrate_instrument_stop('MigrateDestinationEntity->completeFields');
}