You are here

function editor_form_filter_admin_format_editor_configure in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/editor/editor.module \editor_form_filter_admin_format_editor_configure()

Button submit handler for filter_format_form()'s 'editor_configure' button.

1 string reference to 'editor_form_filter_admin_format_editor_configure'
editor_form_filter_format_form_alter in core/modules/editor/editor.module
Implements hook_form_BASE_FORM_ID_alter() for \Drupal\filter\FilterFormatEditForm.

File

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

Code

function editor_form_filter_admin_format_editor_configure($form, FormStateInterface $form_state) {
  $editor = $form_state
    ->get('editor');
  $editor_value = $form_state
    ->getValue([
    'editor',
    'editor',
  ]);
  if ($editor_value !== NULL) {
    if ($editor_value === '') {
      $form_state
        ->set('editor', FALSE);
    }
    elseif (empty($editor) || $editor_value !== $editor
      ->getEditor()) {
      $format = $form_state
        ->getFormObject()
        ->getEntity();
      $editor = Editor::create([
        'format' => $format
          ->isNew() ? NULL : $format
          ->id(),
        'editor' => $editor_value,
      ]);
      $form_state
        ->set('editor', $editor);
    }
  }
  $form_state
    ->setRebuild();
}