You are here

public function SitemapWarmer::addMoreConfigurationFormElements in Warmer 2.x

Same name and namespace in other branches
  1. 8 modules/warmer_cdn/src/Plugin/warmer/SitemapWarmer.php \Drupal\warmer_cdn\Plugin\warmer\SitemapWarmer::addMoreConfigurationFormElements()

Adds additional form elements to the configuration form.

Parameters

array $form: The configuration form to alter for the this plugin settings.

\Drupal\Core\Form\SubformStateInterface $form_state: The form state for the plugin settings.

Return value

array The form with additional elements.

Overrides WarmerInterface::addMoreConfigurationFormElements

File

modules/warmer_cdn/src/Plugin/warmer/SitemapWarmer.php, line 124

Class

SitemapWarmer
The cache warmer for the built-in entity cache.

Namespace

Drupal\warmer_cdn\Plugin\warmer

Code

public function addMoreConfigurationFormElements(array $form, SubformStateInterface $form_state) {

  // Remove manual URLs.
  $configuration = $this
    ->getConfiguration();
  $form['sitemaps'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Sitemaps'),
    '#description' => $this
      ->t('Enter the list of sitemap URLs. One on each line. Examples: https://example.org/sitemap.xml, /drupal-sitemap.xml.'),
    '#default_value' => empty($configuration['sitemaps']) ? '' : implode("\n", $configuration['sitemaps']),
  ];
  $form['minPriority'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Minimum Priority'),
    '#description' => $this
      ->t('URLs with a lower priority than the configured will not be warmed. A float value between 0 and 1.'),
    '#default_value' => empty($configuration['minPriority']) ? 0 : $configuration['minPriority'],
  ];
  $form['headers'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Headers'),
    '#description' => $this
      ->t('Specific headers to use when making HTTP requests. Format: <code>Header-Name: value1; value2</code>'),
    '#default_value' => empty($configuration['headers']) ? '' : implode('\\n\\r', $configuration['headers']),
  ];
  $form['verify'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable SSL verification'),
    '#description' => $this
      ->t('Enable SSL verification. Recommended to keep it checked for security reasons.'),
    '#default_value' => $configuration['verify'],
  ];
  $form['maxConcurrentRequests'] = [
    '#type' => 'number',
    '#min' => 1,
    '#step' => 1,
    '#title' => $this
      ->t('Maximum number of concurrent Requests.'),
    '#description' => $this
      ->t('This defines the maximum number of concurrent requests.'),
    '#default_value' => empty($configuration['maxConcurrentRequests']) ? 10 : $configuration['maxConcurrentRequests'],
  ];
  return $form;
}