function apachesolr_attachments_field_attach_delete in Apache Solr Attachments 7        
                          
                  
                        Same name and namespace in other branches
- 6.3 apachesolr_attachments.module \apachesolr_attachments_field_attach_delete()
File
 
   - ./apachesolr_attachments.module, line 631
- Provides a file attachment search implementation for use with the Apache Solr module
Code
function apachesolr_attachments_field_attach_delete($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 (!empty($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);
          }
        }
      }
    }
  }
}