Security update to Drupal 8.4.6
[yaffs-website] / web / core / modules / block / tests / modules / block_test / src / Controller / TestMultipleFormController.php
1 <?php
2
3 namespace Drupal\block_test\Controller;
4
5 use Drupal\Core\Controller\ControllerBase;
6 use Drupal\Core\Form\FormState;
7
8 /**
9  * Controller for block_test module
10  */
11 class TestMultipleFormController extends ControllerBase {
12
13   public function testMultipleForms() {
14     $form_state = new FormState();
15     $build = [
16       'form1' => $this->formBuilder()->buildForm('\Drupal\block_test\Form\TestForm', $form_state),
17       'form2' => $this->formBuilder()->buildForm('\Drupal\block_test\Form\FavoriteAnimalTestForm', $form_state),
18     ];
19
20     // Output all attached placeholders trough drupal_set_message(), so we can
21     // see if there's only one in the tests.
22     $post_render_callable = function ($elements) {
23       $matches = [];
24       preg_match_all('<form\s(.*?)action="(.*?)"(.*)>', $elements, $matches);
25
26       $action_values = $matches[2];
27
28       foreach ($action_values as $action_value) {
29         drupal_set_message('Form action: ' . $action_value);
30       }
31       return $elements;
32     };
33
34     $build['#post_render'] = [$post_render_callable];
35
36     return $build;
37   }
38
39 }