You are here

public function HttpPurgerFormBase::buildFormPerformance in Generic HTTP Purger 8

Build the 'performance' section of the form.

Parameters

array $form: An associative array containing the structure of the form.

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

\Drupal\purge_purger_http\Entity\HttpPurgerSettings $settings: Configuration entity for the purger being configured.

1 call to HttpPurgerFormBase::buildFormPerformance()
HttpPurgerFormBase::buildForm in src/Form/HttpPurgerFormBase.php
Form constructor.

File

src/Form/HttpPurgerFormBase.php, line 365

Class

HttpPurgerFormBase
Abstract form base for HTTP based configurable purgers.

Namespace

Drupal\purge_purger_http\Form

Code

public function buildFormPerformance(array &$form, FormStateInterface $form_state, HttpPurgerSettings $settings) {
  $form['performance'] = [
    '#type' => 'details',
    '#group' => 'tabs',
    '#title' => $this
      ->t('Performance'),
  ];
  $form['performance']['cooldown_time'] = [
    '#type' => 'number',
    '#step' => 0.1,
    '#min' => 0.0,
    '#max' => 3.0,
    '#title' => $this
      ->t('Cooldown time'),
    '#default_value' => $settings->cooldown_time,
    '#required' => TRUE,
    '#description' => $this
      ->t('Number of seconds to wait after a group of HTTP requests (so that other purgers get fresh content)'),
  ];
  $form['performance']['max_requests'] = [
    '#type' => 'number',
    '#step' => 1,
    '#min' => 1,
    '#max' => 500,
    '#title' => $this
      ->t('Maximum requests'),
    '#default_value' => $settings->max_requests,
    '#required' => TRUE,
    '#description' => $this
      ->t("Maximum number of HTTP requests that can be made during Drupal's execution lifetime. Usually PHP resource restraints lower this value dynamically, but can be met at the CLI."),
  ];
  $form['performance']['runtime_measurement'] = [
    '#title' => $this
      ->t('Runtime measurement'),
    '#type' => 'checkbox',
    '#default_value' => $settings->runtime_measurement,
  ];
  $form['performance']['runtime_measurement_help'] = [
    '#type' => 'item',
    '#states' => [
      'visible' => [
        ':input[name="runtime_measurement"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
    '#description' => $this
      ->t('When you uncheck this setting, capacity will be based on the sum of both timeouts. By default, capacity will automatically adjust (up and down) based on measured time data.'),
  ];
  $form['performance']['timeout'] = [
    '#type' => 'number',
    '#step' => 0.1,
    '#min' => 0.1,
    '#max' => 8.0,
    '#title' => $this
      ->t('Timeout'),
    '#default_value' => $settings->timeout,
    '#required' => TRUE,
    '#states' => [
      'visible' => [
        ':input[name="runtime_measurement"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
    '#description' => $this
      ->t('The timeout of the request in seconds.'),
  ];
  $form['performance']['connect_timeout'] = [
    '#type' => 'number',
    '#step' => 0.1,
    '#min' => 0.1,
    '#max' => 4.0,
    '#title' => $this
      ->t('Connection timeout'),
    '#default_value' => $settings->connect_timeout,
    '#required' => TRUE,
    '#states' => [
      'visible' => [
        ':input[name="runtime_measurement"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
    '#description' => $this
      ->t('The number of seconds to wait while trying to connect to a server.'),
  ];
}