You are here

public function YamlFormController::confirmation in YAML Form 8

Returns a form confirmation page.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request.

\Drupal\yamlform\YamlFormInterface|null $yamlform: A form.

Return value

array A render array representing a form confirmation page

2 string references to 'YamlFormController::confirmation'
yamlform.routing.yml in ./yamlform.routing.yml
yamlform.routing.yml
yamlform_node.routing.yml in modules/yamlform_node/yamlform_node.routing.yml
modules/yamlform_node/yamlform_node.routing.yml

File

src/Controller/YamlFormController.php, line 102

Class

YamlFormController
Provides route responses for form.

Namespace

Drupal\yamlform\Controller

Code

public function confirmation(Request $request, YamlFormInterface $yamlform = NULL) {

  /** @var \Drupal\Core\Entity\EntityInterface $source_entity */
  if (!$yamlform) {
    list($yamlform, $source_entity) = $this->requestHandler
      ->getYamlFormEntities();
  }
  else {
    $source_entity = $this->requestHandler
      ->getCurrentSourceEntity('yamlform');
  }

  /** @var \Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission */
  $yamlform_submission = NULL;
  if ($token = $request
    ->get('token')) {

    /** @var \Drupal\yamlform\YamlFormSubmissionStorageInterface $yamlform_submission_storage */
    $yamlform_submission_storage = $this
      ->entityTypeManager()
      ->getStorage('yamlform_submission');
    if ($entities = $yamlform_submission_storage
      ->loadByProperties([
      'token' => $token,
    ])) {
      $yamlform_submission = reset($entities);
    }
  }
  return [
    '#title' => $source_entity ? $source_entity
      ->label() : $yamlform
      ->label(),
    '#theme' => 'yamlform_confirmation',
    '#yamlform' => $yamlform,
    '#source_entity' => $source_entity,
    '#yamlform_submission' => $yamlform_submission,
  ];
}