You are here

public function HttpPurgerFormBase::buildFormRequest in Generic HTTP Purger 8

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

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

File

src/Form/HttpPurgerFormBase.php, line 182

Class

HttpPurgerFormBase
Abstract form base for HTTP based configurable purgers.

Namespace

Drupal\purge_purger_http\Form

Code

public function buildFormRequest(array &$form, FormStateInterface $form_state, HttpPurgerSettings $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' => array_search($settings->request_method, $this->requestMethods),
    '#options' => $this->requestMethods,
  ];
  $form['request']['scheme'] = [
    '#title' => $this
      ->t('Scheme'),
    '#type' => 'select',
    '#default_value' => array_search($settings->scheme, $this->schemes),
    '#options' => $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' => array_search('https', $this->schemes),
        ],
      ],
    ],
  ];
}