Same name and namespace in other branches
- 8.9.x core/modules/editor/editor.module \editor_form_filter_admin_overview_alter()
- 9 core/modules/editor/editor.module \editor_form_filter_admin_overview_alter()
Implements hook_form_FORM_ID_alter().
File
- core/
modules/ editor/ editor.module, line 75 - 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, [
'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]);
}
}