function editor_form_filter_admin_overview_alter

Same name and namespace in other branches
  1. 9 core/modules/editor/editor.module \editor_form_filter_admin_overview_alter()
  2. 8.9.x core/modules/editor/editor.module \editor_form_filter_admin_overview_alter()
  3. 10 core/modules/editor/editor.module \editor_form_filter_admin_overview_alter()

Implements hook_form_FORM_ID_alter().

File

core/modules/editor/editor.module, line 74

Code

function editor_form_filter_admin_overview_alter(&$form, FormStateInterface $form_state) {
    // @todo Cleanup column injection: https://www.drupal.org/node/1876718.
    // Splice in the column for "Text editor" into the header.
    $position = array_search('name', $form['formats']['#header']) + 1;
    $start = array_splice($form['formats']['#header'], 0, $position, [
        'editor' => t('Text editor'),
    ]);
    $form['formats']['#header'] = array_merge($start, $form['formats']['#header']);
    // Then splice in the name of each text editor for each text format.
    $editors = \Drupal::service('plugin.manager.editor')->getDefinitions();
    foreach (Element::children($form['formats']) as $format_id) {
        $editor = editor_load($format_id);
        $editor_name = $editor && isset($editors[$editor->getEditor()]) ? $editors[$editor->getEditor()]['label'] : '—';
        $editor_column['editor'] = [
            '#markup' => $editor_name,
        ];
        $position = array_search('name', array_keys($form['formats'][$format_id])) + 1;
        $start = array_splice($form['formats'][$format_id], 0, $position, $editor_column);
        $form['formats'][$format_id] = array_merge($start, $form['formats'][$format_id]);
    }
}

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