function apachesolr_attachments_field_attach_update in Apache Solr Attachments 7
Same name and namespace in other branches
- 6.3 apachesolr_attachments.module \apachesolr_attachments_field_attach_update()
1 call to apachesolr_attachments_field_attach_update()
- apachesolr_attachments_field_attach_insert in ./apachesolr_attachments.module
- Hook into the field operations
File
- ./apachesolr_attachments.module, line 599
- Provides a file attachment search implementation for use with the Apache Solr module
Code
function apachesolr_attachments_field_attach_update($parent_entity_type, $parent_entity) {
if (isset($parent_entity->type)) {
foreach (field_info_instances($parent_entity_type, $parent_entity->type) as $instance) {
$field_info = field_info_field($instance['field_name']);
if ($field_info['type'] == 'file') {
module_load_include('inc', 'apachesolr_attachments', 'apachesolr_attachments.index');
$items = field_get_items($parent_entity_type, $parent_entity, $field_info['field_name']);
if ($items) {
foreach ($items as $file_info) {
$file = file_load($file_info['fid']);
if (empty($file)) {
continue;
}
list($parent_entity_id) = entity_extract_ids($parent_entity_type, $parent_entity);
apachesolr_attachments_add_file_usage($file, $parent_entity_type, $parent_entity_id);
}
}
}
}
}
}