public function MigrateFieldsEntityHandler::prepare in Migrate 7.2
File
- plugins/
destinations/ fields.inc, line 64 - Support for processing entity fields
Class
- MigrateFieldsEntityHandler
- @file Support for processing entity fields
Code
public function prepare($entity, stdClass $row) {
migrate_instrument_start('MigrateDestinationEntity->prepareFields');
// 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} = $entity->{$machine_name} ? array(
$entity->{$machine_name},
) : array();
}
$field_info = field_info_field($machine_name);
$entity->{$machine_name} = migrate_field_handler_invoke_all($entity, $field_info, $instance, $entity->{$machine_name});
}
}
migrate_instrument_stop('MigrateDestinationEntity->prepareFields');
}