You are here

public function HttpPurgerFormBase::buildFormMetadata in Generic HTTP Purger 8

Build the 'metadata' 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::buildFormMetadata()
HttpPurgerFormBase::buildForm in src/Form/HttpPurgerFormBase.php
Form constructor.

File

src/Form/HttpPurgerFormBase.php, line 150

Class

HttpPurgerFormBase
Abstract form base for HTTP based configurable purgers.

Namespace

Drupal\purge_purger_http\Form

Code

public function buildFormMetadata(array &$form, FormStateInterface $form_state, HttpPurgerSettings $settings) {
  $form['name'] = [
    '#title' => $this
      ->t('Name'),
    '#type' => 'textfield',
    '#description' => $this
      ->t('A label that describes this purger.'),
    '#default_value' => $settings->name,
    '#required' => TRUE,
  ];
  $types = [];
  foreach ($this->purgeInvalidationFactory
    ->getPlugins() as $type => $definition) {
    $types[$type] = (string) $definition['label'];
  }
  $form['invalidationtype'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Type'),
    '#description' => $this
      ->t('What sort of item will this purger clear?'),
    '#default_value' => $settings->invalidationtype,
    '#options' => $types,
    '#required' => FALSE,
  ];
}