You are here

public function FilterNoFollowList::settingsForm in Nofollow List 8

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/FilterNoFollowList.php, line 55

Class

FilterNoFollowList
Provides a filter to add nofollow to links.

Namespace

Drupal\nofollowlist\Plugin\Filter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {

  // Form to add radio button options to opt between whitelist & blacklist
  // links.
  $form['nofollowlist_option'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Hosts list option'),
    '#description' => $this
      ->t('If you choose the whitelist option, be sure to add your own site to the list!'),
    '#options' => [
      'black' => $this
        ->t('Blacklist: Add rel="nofollow" to links leading to the listed hosts.'),
      'white' => $this
        ->t('Whitelist: Add rel="nofollow" to all links <b>except</b> the listed hosts.'),
    ],
    '#default_value' => $this->settings['nofollowlist_option'],
  ];

  // Form to add textarea to enter links.
  $form['nofollowlist_hosts'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Nofollowlist hosts'),
    '#description' => $this
      ->t('Add one host per line. Ex: en.wikipedia.org'),
    '#default_value' => $this->settings['nofollowlist_hosts'],
  ];
  return $form;
}