diff --git a/field_collection.migrate.inc b/field_collection.migrate.inc index 756fcea..6b37bbb 100644 --- a/field_collection.migrate.inc +++ b/field_collection.migrate.inc @@ -4,9 +4,9 @@ * @file * Support for the Migrate API. * - * Your field collection migration should be run after the host entity migration. - * For example, if the collection is attached to nodes via a field named - * 'field_attached_data', and if the nodes are being imported by + * Your field collection migration should be run after the host entity + * migration. For example, if the collection is attached to nodes via a field + * named 'field_attached_data', and if the nodes are being imported by * ArticleMigration, your collection migration class constructor should look * like: * @@ -54,7 +54,8 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity { } /** - * Returns a list of fields available to be mapped for this collection (bundle). + * Returns a list of fields available to be mapped for this collection + * (bundle). * * @return array * Keys: machine names of the fields (to be passed to addFieldMapping). @@ -70,29 +71,31 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity { * Import a single field collection item. * * @param $collection - * Collection object to build. Pre-filled with any fields mapped in the migration. + * Collection object to build. Pre-filled with any fields mapped in the + * migration. * @param $row * Raw source data object - passed through to prepare/complete handlers. * - * @return array - * Array of key fields (item_id only in this case) of the collection that was saved if - * successful. FALSE on failure. + * @return array|false + * Array of key fields (item_id only in this case) of the collection that was + * saved or FALSE on failure. */ public function import(stdClass $collection, stdClass $row) { if (isset($row->migrate_map_destid1)) { // We're updated an existing entity - start from the previous data. - // entity_load returns an arraym, we get the field collection entity with array_shift + // entity_load() returns an array, so we get the field collection entity + // with array_shift(). $entity = array_shift(entity_load('field_collection_item', array($row->migrate_map_destid1), array(), TRUE)); $updating = TRUE; } else { - // Skip the collection if it has no host + // Skip the collection if it has no host. if (empty($collection->host_entity_id)) { throw new MigrateException('Could not find host entity of the field collection to import.'); } $entity = entity_create('field_collection_item', array('field_name' => $this->bundle)); $updating = FALSE; - // The host entity cannot be reset - we only set it on initial insert + // The host entity cannot be reset - we only set it on initial insert. $host_entity = reset(entity_load($this->hostEntityType, array($collection->host_entity_id), array(), TRUE)); $entity->setHostEntity($this->hostEntityType, $host_entity); } @@ -135,8 +138,8 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity { $this->prepareRollback($item_id); $field_collection_item = field_collection_item_load($item_id); - // If the collection wasn't imported we can't roll it back so check if the - // loaded object matches the fieldcollection item class. + // If the collection wasn't imported then we can't roll it back, so check if + // the loaded object is an instance of the FieldCollectionItemEntity class. if ($field_collection_item instanceof FieldCollectionItemEntity) { $field_collection_item->delete(); }