You are here

function ckeditor_config_uninstall in CKEditor custom config 8.3

Same name and namespace in other branches
  1. 8.2 ckeditor_config.install \ckeditor_config_uninstall()

Implements hook_uninstall().

File

./ckeditor_config.install, line 51
Install, update and uninstall functions for the ckeditor_config module.

Code

function ckeditor_config_uninstall() {

  // Loop through all text formats.
  $filter_formats = filter_formats();
  foreach ($filter_formats as $filter_name => $filter_format) {
    $editor = editor_load($filter_name);
    if (is_null($editor)) {
      continue;
    }
    $editor_name = $editor
      ->getEditor();

    // Only proceed if the editor is 'ckeditor'.
    if ($editor_name == 'ckeditor') {
      $config = \Drupal::service('config.factory')
        ->getEditable('editor.editor.' . $filter_name);
      $settings = $config
        ->get('settings');

      // Remove 'customconfig' settings.
      if (isset($settings['plugins']['customconfig'])) {
        unset($settings['plugins']['customconfig']);
        $config
          ->set('settings', $settings)
          ->save();
      }
    }
  }
}