W3cubDocs

/Drupal 8

function editor_form_filter_admin_overview_alter

editor_form_filter_admin_overview_alter(&$form, FormStateInterface $form_state)

Implements hook_form_FORM_ID_alter() for \Drupal\filter\FilterFormatListBuilder.

File

core/modules/editor/editor.module, line 71
Adds bindings for client-side "text editors" to text formats.

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, array('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'] = array('#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]);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!editor!editor.module/function/editor_form_filter_admin_overview_alter/8.1.x