function _breakpoint_delete_breakpoints

Remove breakpoints from all disabled themes or uninstalled modules.

The source type has to match the original source type, otherwise the group will not be deleted. All groups created by the theme or module will be deleted as well.

Parameters

array $list: A list of modules or themes that are disabled.

string $source_type: Either Breakpoint::SOURCE_TYPE_THEME or Breakpoint::SOURCE_TYPE_MODULE.

2 calls to _breakpoint_delete_breakpoints()
breakpoint_modules_uninstalled in drupal/core/modules/breakpoint/breakpoint.module
Implements hook_modules_uninstalled().
breakpoint_themes_disabled in drupal/core/modules/breakpoint/breakpoint.module
Implements hook_themes_disabled().

File

drupal/core/modules/breakpoint/breakpoint.module, line 189
Manage breakpoints and breakpoint groups for responsive designs.

Code

function _breakpoint_delete_breakpoints($list, $source_type) {
  $ids = config_get_storage_names_with_prefix('breakpoint.breakpoint_group.' . $source_type . '.');
  $entity_info = entity_get_info('breakpoint_group');

  // Remove the breakpoint.breakpoint part of the breakpoint identifier.
  foreach ($ids as &$id) {
    $id = ConfigStorageController::getIDFromConfigName($id, $entity_info['config_prefix']);
  }
  $breakpoint_groups = entity_load_multiple('breakpoint_group', $ids);
  foreach ($breakpoint_groups as $breakpoint_group) {
    if ($breakpoint_group->sourceType == $source_type && in_array($breakpoint_group->source, $list)) {

      // Delete the automatically created breakpoint group.
      $breakpoint_group
        ->delete();

      // Get all breakpoints defined by this theme/module.
      $breakpoint_ids = drupal_container()
        ->get('config.storage')
        ->listAll('breakpoint.breakpoint.' . $source_type . '.' . $breakpoint_group
        ->id() . '.');
      $entity_info = entity_get_info('breakpoint');

      // Remove the breakpoint.breakpoint part of the breakpoint identifier.
      foreach ($breakpoint_ids as &$breakpoint_id) {
        $breakpoint_id = ConfigStorageController::getIDFromConfigName($breakpoint_id, $entity_info['config_prefix']);
      }
      $breakpoints = entity_load_multiple('breakpoint', $breakpoint_ids);

      // Make sure we only delete breakpoints defined by this theme/module.
      foreach ($breakpoints as $breakpoint) {
        if ($breakpoint->sourceType == $source_type && $breakpoint->source == $breakpoint_group->name) {
          $breakpoint
            ->delete();
        }
      }
    }
  }

  // Delete groups defined by a module/theme even if that module/theme didn't
  // define any breakpoints.
  foreach ($ids as $id) {

    // Delete all breakpoint groups defined by the theme or module.
    _breakpoint_delete_breakpoint_groups($id, $source_type);
  }
}