You are here

public function FormTestController::storageLegacyHandler in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php \Drupal\form_test\Controller\FormTestController::storageLegacyHandler()
  2. 9 core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php \Drupal\form_test\Controller\FormTestController::storageLegacyHandler()

Emulate legacy AHAH-style ajax callback.

Drupal 6 AHAH callbacks used to operate directly on forms retrieved using \Drupal::formBuilder()->getCache() and stored using \Drupal::formBuilder()->setCache() after manipulation. This callback helps testing whether \Drupal::formBuilder()->setCache() prevents resaving of immutable forms.

1 string reference to 'FormTestController::storageLegacyHandler'
form_test.routing.yml in core/modules/system/tests/modules/form_test/form_test.routing.yml
core/modules/system/tests/modules/form_test/form_test.routing.yml

File

core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php, line 45

Class

FormTestController
Controller routines for form_test routes.

Namespace

Drupal\form_test\Controller

Code

public function storageLegacyHandler($form_build_id) {
  $form_state = new FormState();
  $form = $this
    ->formBuilder()
    ->getCache($form_build_id, $form_state);
  $result = [
    'form' => $form,
    'form_state' => $form_state,
  ];
  $form['#poisoned'] = TRUE;
  $form_state
    ->set('poisoned', TRUE);
  $this
    ->formBuilder()
    ->setCache($form_build_id, $form, $form_state);
  return new JsonResponse($result);
}