function webform_test_preprocess_webform_confirmation in Webform 6.x
Same name and namespace in other branches
- 8.5 tests/modules/webform_test/webform_test.module \webform_test_preprocess_webform_confirmation()
Implements hook_preprocess_webform_confirmation().
File
- tests/
modules/ webform_test/ webform_test.module, line 54 - Support module for webform related testing.
Code
function webform_test_preprocess_webform_confirmation(array &$variables) {
/** @var \Drupal\webform\WebformInterface $webform */
$webform = $variables['webform'];
switch ($webform
->id()) {
case 'test_states_to_text':
/** @var \Drupal\webform\WebformEntityConditionsManagerInterface $conditions_manager */
$conditions_manager = \Drupal::service('webform.conditions_manager');
$build = [];
$elements = $webform
->getElementsInitializedAndFlattened();
foreach ($elements as $element_key => $element) {
if (isset($element['#states'])) {
$build[$element_key] = [
'#type' => 'item',
'#title' => $element['#admin_title'],
'text' => $conditions_manager
->toText($webform, $element['#states']),
];
}
}
$variables['message'] = $build;
return;
}
}