You are here

function block_style_plugins_themes_uninstalled in Block Style Plugins 8.2

Same name and namespace in other branches
  1. 8 block_style_plugins.module \block_style_plugins_themes_uninstalled()

Implements hook_themes_uninstalled().

File

./block_style_plugins.module, line 83
Contains block_style_plugins.module.

Code

function block_style_plugins_themes_uninstalled(array $themes) {

  // Clear the Plugins cache when a theme using a plugin is uninstalled.

  /** @var Drupal\block_style_plugins\Plugin\BlockStyleManager $plugin_manager */
  $plugin_manager = \Drupal::service('plugin.manager.block_style.processor');
  $style_plugins = $plugin_manager
    ->getDefinitions();
  $clear_cache = FALSE;
  foreach ($themes as $theme_name) {
    foreach ($style_plugins as $plugin) {
      if ($plugin['provider'] == $theme_name) {
        $clear_cache = TRUE;
        break;
      }
    }
  }

  // Clear all plugin caches.
  if ($clear_cache) {
    \Drupal::service('plugin.cache_clearer')
      ->clearCachedDefinitions();
  }
}