public function EnqueueForm::submitForm in Warmer 8
Same name and namespace in other branches
- 2.x src/Form/EnqueueForm.php \Drupal\warmer\Form\EnqueueForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ EnqueueForm.php, line 140
Class
- EnqueueForm
- A form to manually enqueue warming operations.
Namespace
Drupal\warmer\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$warmer_ids = $form_state
->getValue('warmers');
$warmers = $this->warmerManager
->getWarmers($warmer_ids);
$count_list = array_map(function (WarmerPluginBase $warmer) {
$count = 0;
$ids = [
NULL,
];
while ($ids = $warmer
->buildIdsBatch(end($ids))) {
$this->queueManager
->enqueueBatch(HookImplementations::class . '::warmBatch', $ids, $warmer);
$count += count($ids);
}
return $count;
}, $warmers);
$total = array_sum($count_list);
$this->messenger
->addStatus($this
->t('@total items enqueued for cache warming.', [
'@total' => $total,
]));
}