1 file.admin.inc file_type_save($type)

Updates an existing file type or creates a new one.

This function can be called on its own, or via the CTools exportables 'save callback' for {file_type} objects.

File

core/modules/file/file.admin.inc, line 599
Admin page callbacks for the File module.

Code

function file_type_save($type) {
  $type_data = (array) $type;
  if (!isset($type->description)) {
    $type_data['description'] = '';
  }

  $config = config('file.type.' . $type->type);
  foreach ($type_data as $key => $value) {
    $config->set($key, $value);
  }
  $config->save();

  if (empty($type->is_new)) {
    module_invoke_all('file_type_update', $type);
    $status = SAVED_UPDATED;
  }
  else {
    module_invoke_all('file_type_insert', $type);
    $status = SAVED_NEW;
  }

  // Clear the necessary caches.
  file_type_cache_reset();

  return $status;
}