function ckeditor_config_update_8200 in CKEditor custom config 8.3
Same name and namespace in other branches
- 8.2 ckeditor_config.install \ckeditor_config_update_8200()
Move global config to individual CKEditor editors. Delete disused permission.
File
- ./
ckeditor_config.install, line 13 - Install, update and uninstall functions for the ckeditor_config module.
Code
function ckeditor_config_update_8200() {
// Load configuration from 8.x-1.x.
$config_previous = \Drupal::service('config.factory')
->get('ckeditor_config.config_form')
->get('config');
// 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');
$settings['plugins']['customconfig']['ckeditor_custom_config'] = $config_previous;
$config
->set('settings', $settings)
->save();
}
}
// Delete configuration from 8.x-1.x.
\Drupal::service('config.factory')
->getEditable('ckeditor_config.config_form')
->delete();
// Loop through roles and revoke disused permission.
$roles = Role::loadMultiple();
foreach ($roles as $role) {
$role
->revokePermission('ckeditor config')
->save();
}
}