You are here

public function VarnishPurgerFormBase::buildFormPerformance in Varnish purger 8.2

Same name and namespace in other branches
  1. 8 src/Form/VarnishPurgerFormBase.php \Drupal\varnish_purger\Form\VarnishPurgerFormBase::buildFormPerformance()

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\varnish_purger\Entity\VarnishPurgerSettings $settings: Configuration entity for the purger being configured.

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

File

src/Form/VarnishPurgerFormBase.php, line 289

Class

VarnishPurgerFormBase
Abstract form base for Varnish based configurable purgers.

Namespace

Drupal\varnish_purger\Form

Code

public function buildFormPerformance(array &$form, FormStateInterface $form_state, VarnishPurgerSettings $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' => 50000,
    '#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.'),
  ];
}