function file_type_delete in File Entity (fieldable files) 7.2
Same name and namespace in other branches
- 7.3 file_entity.file_api.inc \file_type_delete()
Deletes a file type from the database.
This function can be called on its own, or via the CTools exportables 'delete callback' for {file_type} objects.
Parameters
object|string $type: Either a loaded file type object or the machine-name of the type.
Related topics
3 calls to file_type_delete()
- file_entity_type_delete_confirm_submit in ./
file_entity.admin.inc - Process file type delete confirm submissions.
- file_entity_type_revert_confirm_submit in ./
file_entity.admin.inc - Process file type delete confirm submissions.
- file_entity_uninstall in ./
file_entity.install - Implements hook_uninstall().
2 string references to 'file_type_delete'
- file_entity_schema in ./
file_entity.install - Implements hook_schema().
- file_entity_update_7201 in ./
file_entity.install - Add the {file_type}, {file_type_mimetypes} tables.
File
- ./
file_entity.file_api.inc, line 623 - API extensions of Drupal core's file.inc.
Code
function file_type_delete($type) {
$type = is_string($type) ? file_type_load($type) : $type;
db_delete('file_type')
->condition('type', $type->type)
->execute();
// Remove this type from CToolS status variable.
$status = variable_get('default_file_type', array());
unset($status[$type->type]);
variable_set('default_file_type', $status);
file_info_cache_clear();
// After deleting from the database, check if the type still exists as a
// code-provided default type. If not, consider the type fully deleted and
// invoke the needed hooks.
if (!file_type_load($type->type)) {
field_attach_delete_bundle('file', $type->type);
module_invoke_all('file_type_delete', $type);
}
}