public function BigPipeAddToCartForm::buildForm in Commerce Core 8.2
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 AddToCartForm::buildForm
File
- modules/
cart/ tests/ modules/ commerce_cart_big_pipe/ src/ Form/ BigPipeAddToCartForm.php, line 16
Class
- BigPipeAddToCartForm
- Provides a slow to build add to cart form, to test streaming.
Namespace
Drupal\commerce_cart_big_pipe\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Sleep between 0.0 and 2.0 seconds.
$load_slowdown = mt_rand(0, 20) / 10;
$this
->messenger()
->addMessage(sprintf('Delayed form build by %s seconds', $load_slowdown));
sleep($load_slowdown);
return parent::buildForm($form, $form_state);
}