You are here

public function GeshiFilterFilter::settingsForm in GeSHi Filter for syntax highlighting 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Filter/GeshiFilterFilter.php \Drupal\geshifilter\Plugin\Filter\GeshiFilterFilter::settingsForm()

Create the settings form for the filter.

@todo Add validation of submited form values, it already exists for drupal 7, must update it only.

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/GeshiFilterFilter.php, line 406

Class

GeshiFilterFilter
Provides a base filter for Geshi Filter.

Namespace

Drupal\geshifilter\Plugin\Filter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  if ($this->configEditable
    ->get('use_format_specific_options')) {

    // Tags and attributes.
    $form['general_tags'] = $this
      ->generalHighlightTagsSettings();

    // Per language tags.
    $form['per_language_settings'] = [
      '#type' => 'fieldset',
      '#title' => $this
        ->t('Per language tags'),
      '#collapsible' => TRUE,
      'table' => $this
        ->perLanguageSettings('enabled', FALSE, TRUE),
    ];

    // Validate the tags
    // $form['#validate'][] = '::validateForm';.
  }
  else {
    $form['info'] = [
      '#markup' => '<p>' . $this
        ->t('GeSHi filter is configured to use global tag
          settings. For separate settings per text format, enable this option in
          the <a href=":geshi_admin_url">general GeSHi filter settings</a>.', [
        ':geshi_admin_url' => Url::fromRoute('geshifilter.settings')
          ->toString(),
      ]) . '</p>',
    ];
  }
  return $form;
}