function _uuid_features_drush_update_file in UUID Features Integration 7
Same name and namespace in other branches
- 6 includes/uuid_features.drush.inc \_uuid_features_drush_update_file()
Copy the file identified by $uuid into the feature specified by $module.
Parameters
string $module: The module.
string $uuid: The uuid.
1 call to _uuid_features_drush_update_file()
- uuid_features_command_update_files in includes/
uuid_features.drush.inc - Update files for features modules that use the uuid_file component.
File
- includes/
uuid_features.drush.inc, line 87 - uuid_features module drush integration.
Code
function _uuid_features_drush_update_file($module, $uuid) {
$fid = uuid_get_serial_id('files', 'fid', $uuid);
if (empty($fid) || !($file = field_file_load($fid))) {
drush_set_error('UUID_FILE_NOT_FOUND', dt('The file specified by %uuid was not found.', array(
'%uuid' => $uuid,
)));
}
$root = drush_get_option(array(
'r',
'root',
), drush_locate_root());
if ($root) {
$directory = drupal_get_path('module', $module) . '/uuid_file';
if (!is_dir($directory)) {
drush_op('mkdir', $directory);
}
$source = $file['filepath'];
$file_parts = explode('.', $file['filepath']);
$extension = array_pop($file_parts);
$destination = $directory . '/' . $uuid . '.' . $extension;
drush_op('copy', $source, $destination);
drush_log(dt("Updated file: !uuid - !filename", array(
'!uuid' => $uuid,
'!filename' => basename($destination),
)), 'ok');
}
else {
drush_die(dt('Couldn\'t locate site root'));
}
}