You are here

public function VarnishPurgerFormBase::buildFormRequest in Varnish purger 8.2

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

Build the 'request' 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::buildFormRequest()
VarnishPurgerFormBase::buildForm in src/Form/VarnishPurgerFormBase.php
Form constructor.

File

src/Form/VarnishPurgerFormBase.php, line 144

Class

VarnishPurgerFormBase
Abstract form base for Varnish based configurable purgers.

Namespace

Drupal\varnish_purger\Form

Code

public function buildFormRequest(array &$form, FormStateInterface $form_state, VarnishPurgerSettings $settings) {
  $form['request'] = [
    '#type' => 'details',
    '#group' => 'tabs',
    '#title' => $this
      ->t('Request'),
    '#description' => $this
      ->t('In this section you configure how a single HTTP request looks like.'),
  ];
  $form['request']['hostname'] = [
    '#title' => $this
      ->t('Hostname'),
    '#type' => 'textfield',
    '#default_value' => $settings->hostname,
  ];
  $form['request']['port'] = [
    '#title' => $this
      ->t('Port'),
    '#type' => 'textfield',
    '#default_value' => $settings->port,
  ];
  $form['request']['path'] = [
    '#title' => $this
      ->t('Path'),
    '#type' => 'textfield',
    '#default_value' => $settings->path,
  ];
  $form['request']['request_method'] = [
    '#title' => $this
      ->t('Request Method'),
    '#type' => 'select',
    '#default_value' => $this->request_methods[(int) array_search($settings->request_method, $this->request_methods)],
    '#options' => array_combine($this->request_methods, $this->request_methods),
  ];
  $form['request']['scheme'] = [
    '#title' => $this
      ->t('Scheme'),
    '#type' => 'select',
    '#default_value' => $this->schemes[(int) array_search($settings->scheme, $this->schemes)],
    '#options' => array_combine($this->schemes, $this->schemes),
  ];
  $form['request']['verify'] = [
    '#title' => $this
      ->t('Verify SSL certificate'),
    '#type' => 'checkbox',
    '#description' => $this
      ->t("Uncheck to disable certificate verification (this is insecure!)."),
    '#default_value' => $settings->verify,
    '#states' => [
      'visible' => [
        ':input[name="scheme"]' => [
          'value' => 'https',
        ],
      ],
    ],
  ];
}