function template_preprocess_yamlform_confirmation in YAML Form 8
Prepares variables for form confirmation templates.
Default template: yamlform-confirmation.html.twig.
Parameters
array $variables: An associative array containing the following key:
- yamlform_submission: A form submission.
 
File
- includes/
yamlform.theme.inc, line 129  - Preprocessors and helper functions to make theming easier.
 
Code
function template_preprocess_yamlform_confirmation(array &$variables) {
  /** @var \Drupal\yamlform\YamlFormInterface $yamlform */
  $yamlform = $variables['yamlform'];
  /** @var \Drupal\Core\Entity\EntityInterface $source_entity */
  $source_entity = $variables['source_entity'];
  /** @var \Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission */
  $yamlform_submission = $variables['yamlform_submission'];
  /** @var \Drupal\yamlform\YamlFormMessageManagerInterface $message_manager */
  $message_manager = \Drupal::service('yamlform.message_manager');
  $message_manager
    ->setYamlForm($yamlform);
  $message_manager
    ->setSourceEntity($source_entity);
  $message_manager
    ->setYamlFormSubmission($yamlform_submission);
  $settings = $yamlform
    ->getSettings();
  // Set progress.
  if ($yamlform
    ->getPages() && $settings['wizard_complete'] && ($settings['wizard_progress_bar'] || $settings['wizard_progress_pages'] || $settings['wizard_progress_percentage'])) {
    $variables['progress'] = [
      '#theme' => 'yamlform_progress',
      '#yamlform' => $yamlform,
      '#current_page' => 'complete',
    ];
  }
  // Set message.
  $variables['message'] = $message_manager
    ->build(YamlFormMessageManagerInterface::SUBMISSION_CONFIRMATION);
  // Set attributes.
  $variables['attributes'] = new Attribute($settings['confirmation_attributes']);
  // Set back.
  $variables['back'] = $settings['confirmation_back'];
  $variables['back_label'] = $settings['confirmation_back_label'] ?: \Drupal::config('yamlform.settings')
    ->get('settings.default_confirmation_back_label');
  $variables['back_attributes'] = new Attribute($settings['confirmation_back_attributes']);
  // Apply all passed query string parameters to the 'Back to form' link.
  $query = \Drupal::request()->query
    ->all();
  unset($query['yamlform_id']);
  $options = $query ? [
    'query' => $query,
  ] : [];
  // Set back_url.
  if ($source_entity) {
    $variables['back_url'] = $source_entity
      ->toUrl('canonical', $options)
      ->toString();
  }
  elseif ($yamlform_submission) {
    $variables['back_url'] = $yamlform_submission
      ->getSourceUrl()
      ->toString();
  }
  else {
    $variables['back_url'] = $yamlform
      ->toUrl('canonical', $options)
      ->toString();
  }
}