function filefield_paths_batch_update in File (Field) Paths 7
Same name and namespace in other branches
- 8 filefield_paths.module \filefield_paths_batch_update()
- 6 filefield_paths.module \filefield_paths_batch_update()
Set batch process to update File (Field) Paths.
Parameters
$instance:
Return value
bool
2 calls to filefield_paths_batch_update()
- filefield_paths_form_submit in ./
filefield_paths.module - Submit callback for File (Field) Paths settings form.
- _filefield_paths_drush_ffp_update in ./
filefield_paths.drush.inc - Helper function; Invokes File (Field) Paths Retroactive updates.
File
- ./
filefield_paths.module, line 235 - Contains core functions for the File (Field) Paths module.
Code
function filefield_paths_batch_update($instance) {
$query = new EntityFieldQuery();
$result = $query
->entityCondition('entity_type', $instance['entity_type'])
->entityCondition('bundle', array(
$instance['bundle'],
))
->fieldCondition($instance['field_name'])
->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT')
->execute();
// If there are no results, do not set a batch as there is nothing to process.
if (empty($result[$instance['entity_type']])) {
return FALSE;
}
$objects = array_keys($result[$instance['entity_type']]);
$instance = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
// Create batch.
$batch = array(
'title' => t('Updating File (Field) Paths'),
'operations' => array(
array(
'_filefield_paths_batch_update_process',
array(
$objects,
$instance,
),
),
),
);
batch_set($batch);
return TRUE;
}