function ckeditor5_module_implements_alter

Same name and namespace in other branches
  1. 9 core/modules/ckeditor5/ckeditor5.module \ckeditor5_module_implements_alter()
  2. 10 core/modules/ckeditor5/ckeditor5.module \ckeditor5_module_implements_alter()

Implements hook_module_implements_alter().

File

core/modules/ckeditor5/ckeditor5.module, line 97

Code

function ckeditor5_module_implements_alter(&$implementations, $hook) {
    // This module's implementation of form_filter_format_form_alter() must happen
    // after the editor module's implementation, as that implementation adds the
    // active editor to $form_state. It must also happen after the media module's
    // implementation so media_filter_format_edit_form_validate can be removed
    // from the validation chain, as that validator is not needed with CKEditor 5
    // and will trigger a false error.
    if ($hook === 'form_alter' && isset($implementations['ckeditor5']) && isset($implementations['editor'])) {
        $group = $implementations['ckeditor5'];
        unset($implementations['ckeditor5']);
        $offset = array_search('editor', array_keys($implementations)) + 1;
        if (array_key_exists('media', $implementations)) {
            $media_offset = array_search('media', array_keys($implementations)) + 1;
            $offset = max([
                $offset,
                $media_offset,
            ]);
        }
        $implementations = array_slice($implementations, 0, $offset, TRUE) + [
            'ckeditor5' => $group,
        ] + array_slice($implementations, $offset, NULL, TRUE);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.