function filefield_paths_field_storage_pre_update in File (Field) Paths 7
Implements hook_field_storage_pre_update().
Parameters
$entity_type:
$entity:
1 call to filefield_paths_field_storage_pre_update()
File
- ./
filefield_paths.module, line 329 - Contains core functions for the File (Field) Paths module.
Code
function filefield_paths_field_storage_pre_update($entity_type, $entity) {
$field_types = _filefield_paths_get_field_types();
$entity_info = entity_get_info($entity_type);
list(, , $bundle) = entity_extract_ids($entity_type, $entity);
if ($entity_info['fieldable']) {
foreach (field_info_fields() as $field) {
if (in_array($field['type'], array_keys($field_types))) {
$files = array();
$instance = field_info_instance($entity_type, $field['field_name'], $bundle);
$enabled = isset($instance['settings']['filefield_paths_enabled']) && $instance['settings']['filefield_paths_enabled'] || !isset($instance['settings']['filefield_paths_enabled']);
if ($enabled && isset($entity->{$field['field_name']}) && is_array($entity->{$field['field_name']})) {
foreach ($entity->{$field['field_name']} as $langcode => &$deltas) {
foreach ($deltas as $delta => &$file) {
// Prepare file.
if (function_exists($function = "{$field['module']}_field_load")) {
$items = array(
array(
&$file,
),
);
$function($entity_type, array(
$entity,
), $field, array(
$instance,
), $langcode, $items, FIELD_LOAD_CURRENT);
}
$files[] =& $file;
}
// Invoke hook_filefield_paths_process_file().
foreach (module_implements('filefield_paths_process_file') as $module) {
if (function_exists($function = "{$module}_filefield_paths_process_file")) {
$function($entity_type, $entity, $field, $instance, $langcode, $files);
}
}
}
}
}
}
}
}