$uuid, 'hash' => md5_file($file['filepath']), 'extension' => $extension, ); $code[] = ' $files[] = ' . features_var_export($export, ' ') . ';'; } if (!empty($translatables)) { $code[] = features_translatables_export($translatables, ' '); } $code[] = ' return $files;'; $code = implode("\n", $code); return array('uuid_features_default_files' => $code); } /** * Implements hook_features_revert(). */ function uuid_file_features_revert($module) { uuid_file_features_rebuild($module); } /** * Implements hook_features_rebuild(). * Rebuilds files based on UUID from code defaults. */ function uuid_file_features_rebuild($module) { $files = module_invoke($module, 'uuid_features_default_files'); if (!empty($files)) { $source_dir = drupal_get_path('module', $module) . '/uuid_file'; foreach ($files as $data) { $source = $source_dir . '/' . $data['uuid'] . '.' . $data['extension']; $data = file_get_contents($source); // Copy the file and save to db. $file = file_save_data($data, NULL, FILE_EXISTS_REPLACE); } } }