function uuid_features_fetch_uuid_references in UUID Features Integration 7
Walks through list of fields and updates entity references using the UUID.
Parameters
array $fields: Filtered array of fields of the same type.
string $entity_type: The entity type.
array $map: Mapping from entity to reference fields properties. Example: Taxonomy term: array( 'tid' => 'tid', )
Field collection: array( 'item_id' => 'value', 'revision_id' => 'revision_id', )
5 calls to uuid_features_fetch_uuid_references()
- commerce_product_reference_uuid_entity_features_rebuild_alter in includes/
modules/ commerce_product_reference.inc - Implements hook_uuid_entity_features_rebuild_alter().
- field_collection_uuid_entity_features_rebuild_alter in includes/
modules/ field_collection.inc - Implements hook_uuid_entity_features_rebuild_alter().
- paragraphs_uuid_entity_features_rebuild_alter in includes/
modules/ paragraphs.inc - Implements hook_uuid_entity_features_rebuild_alter().
- taxonomy_uuid_entity_features_rebuild_alter in includes/
modules/ taxonomy.inc - Implements hook_uuid_entity_features_rebuild_alter().
- _entity_reference_uuid_entity_features_rebuild_fetch_uuid_references in includes/
modules/ entityreference.inc - Helper function to fetch uuid references in case of different fields types.
File
- ./
uuid_features.module, line 913 - UUID Features module allows to export data stored in the db by features.
Code
function uuid_features_fetch_uuid_references(&$fields, $entity_type, $map) {
foreach ($fields as $field_name => &$field_languages) {
foreach ($field_languages as &$field_values) {
if (is_array($field_values)) {
foreach ($field_values as &$field_value) {
$uuid = 'not found';
if (isset($field_value['uuid'])) {
$uuid = $field_value['uuid'];
}
else {
// Try our best to load a reference even if the explicit uuid key is
// missing. It's likely that the uuid was stored in the first map
// key. This is for backward compatibility.
$target_key = reset($map);
if (isset($field_value[$target_key]) && uuid_is_valid($field_value[$target_key])) {
$uuid = $field_value[$target_key];
}
}
if ($uuid != 'not found') {
$entities = entity_uuid_load($entity_type, array(
$uuid,
), array(), TRUE);
$referenced_entity = reset($entities);
foreach ($map as $source => $destination) {
if ($referenced_entity) {
$field_value[$destination] = $referenced_entity->{$source};
}
else {
// Fallback.
$field_value[$destination] = UUID_FEATURES_DEFAULT_FALLBACK_ID;
}
}
}
}
}
}
}
}