function uuid_features_file_field_import in UUID Features Integration 7
Handle importing file fields.
7 calls to uuid_features_file_field_import()
- uuid_bean_features_rebuild in includes/
uuid_bean.features.inc - Implements hook_features_rebuild().
- uuid_commerce_product_features_rebuild_products in includes/
uuid_commerce_product.features.inc - Runs the product import multiple times to resolve dependencies.
- uuid_field_collection_features_rebuild in includes/
uuid_field_collection.features.inc - Implements hook_features_rebuild().
- uuid_fpp_features_rebuild in includes/
uuid_fpp.features.inc - Implements hook_features_rebuild().
- uuid_node_features_rebuild_nodes in includes/
uuid_node.features.inc - Runs the node import multiple times to resolve dependencies.
File
- ./
uuid_features.module, line 618 - UUID Features module allows to export data stored in the db by features.
Code
function uuid_features_file_field_import(&$import, $entity_type, $module = NULL) {
list($entity_id, $revision_id, $import_bundle) = entity_extract_ids($entity_type, $import);
// Get all fields from this bundle.
$fields = field_info_instances($entity_type, $import_bundle);
foreach ($fields as $field_instance) {
if (isset($import->{$field_instance['field_name']})) {
// Load field info to check the type.
$field =& $import->{$field_instance['field_name']};
$info = field_info_field($field_instance['field_name']);
$supported_fields = array_map('trim', explode(',', variable_get('uuid_features_file_supported_fields', 'file, image')));
// Check if this field should implement file import/export system.
if (in_array($info['type'], $supported_fields)) {
// We need to loop into each language because i18n translation can build
// fields with different language than the term one.
foreach ($field as $language => $files) {
if (is_array($files)) {
foreach ($files as $i => $file) {
// Convert file to array to stay into the default
// uuid_features_file format.
$file_object = (object) $file;
$result = _uuid_features_file_field_import_file($file_object, $module);
// The file was saved successfully, update the file field
// (by reference).
if ($result == TRUE && isset($file_object->fid)) {
// Mash up the file object and the file field data to ensure
// all data are present. The handling might strip properties
// required by the field that stores the file.
$field[$language][$i] = (array) $file_object + $file;
}
else {
$field[$language][$i] = array();
}
}
}
}
}
}
}
}