function CKEditor5::injectPluginSettingsForm

Same name in other branches
  1. 9 core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php \Drupal\ckeditor5\Plugin\Editor\CKEditor5::injectPluginSettingsForm()
  2. 11.x core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php \Drupal\ckeditor5\Plugin\Editor\CKEditor5::injectPluginSettingsForm()

Injects the CKEditor plugins settings forms as a vertical tabs subform.

Parameters

array &$form: A reference to an associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

\Drupal\editor\EditorInterface $editor: A configured text editor object.

1 call to CKEditor5::injectPluginSettingsForm()
CKEditor5::buildConfigurationForm in core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php
Form constructor.

File

core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php, line 480

Class

CKEditor5
Defines a CKEditor 5-based text editor for Drupal.

Namespace

Drupal\ckeditor5\Plugin\Editor

Code

private function injectPluginSettingsForm(array &$form, FormStateInterface $form_state, EditorInterface $editor) : void {
    $definitions = $this->ckeditor5PluginManager
        ->getDefinitions();
    $eventual_editor_and_format = $this->getEventualEditorWithPrimedFilterFormat($form_state, $editor);
    foreach ($definitions as $plugin_id => $definition) {
        if ($definition->isConfigurable() && $this->shouldHaveVisiblePluginSettingsForm($definition, $eventual_editor_and_format)) {
            $plugin = $this->ckeditor5PluginManager
                ->getPlugin($plugin_id, $editor);
            $plugin_settings_form = [];
            $form['plugins'][$plugin_id] = [
                '#type' => 'details',
                '#title' => $definition->label(),
                '#open' => TRUE,
                '#group' => 'editor][settings][plugin_settings',
                '#attributes' => [
                    'data-ckeditor5-plugin-id' => $plugin_id,
                ],
            ];
            $form['plugins'][$plugin_id] += $plugin->buildConfigurationForm($plugin_settings_form, $form_state);
        }
    }
}

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