You are here

public function GutenbergFilter::settingsForm in Gutenberg 8.2

Generates a filter's settings form.

Parameters

array $form: A minimally prepopulated form array.

\Drupal\Core\Form\FormStateInterface $form_state: The state of the (entire) configuration form.

Return value

array The $form array with additional form elements for the settings of this filter. The submitted form values should match $this->settings.

Overrides FilterBase::settingsForm

File

src/Plugin/Filter/GutenbergFilter.php, line 134

Class

GutenbergFilter
Provides a filter for Gutenberg blocks.

Namespace

Drupal\gutenberg\Plugin\Filter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $processors_settings = [];
  $this
    ->setProviderSettings();
  $processors = $this->blockProcessorManager
    ->getSortedProcessors();
  foreach ($processors as $processor) {
    if ($processor instanceof GutenbergConfigurableBlockProcessorInterface) {
      $processors_settings += $processor
        ->provideSettings($form, $form_state);
    }
  }
  if ($processors_settings) {
    $form['processor_settings'] = $processors_settings;
    return $form;
  }

  // Empty array to signify that there is no configuration.
  return [];
}