You are here

public static function ScaldAtomController::removeType in Scald: Media Management made easy 7

Remove a Scald unified type.

This function removes a type. It can be used inside atom providers hook_uninstall(), to easily ensure that the type of the atom the module provides is removed if no other use it.

Parameters

string $type: Machine name of atom type.

Return value

bool TRUE if the type was removed, FALSE otherwise.

5 calls to ScaldAtomController::removeType()
scald_audio_uninstall in modules/providers/scald_audio/scald_audio.install
Implements hook_uninstall().
scald_flash_uninstall in modules/providers/scald_flash/scald_flash.install
Implements hook_uninstall().
scald_image_uninstall in modules/providers/scald_image/scald_image.install
Implements hook_uninstall().
scald_remove_type in ./scald.module
Remove a Scald unified type.
scald_video_uninstall in modules/providers/scald_video/scald_video.install
Implements hook_uninstall().

File

includes/ScaldAtomController.inc, line 176
This file contains the Scald Atom controller.

Class

ScaldAtomController
Controller class for Scald Atoms.

Code

public static function removeType($type) {
  if (!array_key_exists($type, scald_atom_providers())) {
    db_delete('scald_types')
      ->condition('type', $type)
      ->execute();
    scald_types(TRUE);
    foreach (array(
      'scald_thumbnail',
      'scald_authors',
      'scald_tags',
    ) as $field_name) {
      $instance = field_info_instance('scald_atom', $field_name, $type);
      if (!empty($instance)) {
        field_delete_instance($instance, FALSE);
      }
    }
    return TRUE;
  }
  return FALSE;
}