You are here

public function SettingsForm::buildForm in Warmer 8

Same name and namespace in other branches
  1. 2.x src/Form/SettingsForm.php \Drupal\warmer\Form\SettingsForm::buildForm()

Form constructor.

Parameters

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

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

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/SettingsForm.php, line 62

Class

SettingsForm
Settings form for the warmer module.

Namespace

Drupal\warmer\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $form['help'] = [
    '#type' => 'html_tag',
    '#tag' => 'p',
    '#value' => $this
      ->t('Configure the cache warming behaviors. Each cache warmer is a plugin that may contain specific settings. They are all configured here.'),
  ];
  $warmers = $this->warmerManager
    ->getWarmers();
  $form['warmers'] = [
    '#type' => 'vertical_tabs',
    '#title' => $this
      ->t('Warmers'),
  ];
  $subform_state = SubformState::createForSubform($form, $form, $form_state);
  $form += array_reduce($warmers, function ($carry, WarmerPluginBase $warmer) use ($subform_state) {
    return $warmer
      ->buildConfigurationForm($carry, $subform_state) + $carry;
  }, $form);
  return $form;
}