public function WebformEntityController::confirmation in Webform 8.5
Same name and namespace in other branches
- 6.x src/Controller/WebformEntityController.php \Drupal\webform\Controller\WebformEntityController::confirmation()
Returns a webform confirmation page.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The current request.
\Drupal\webform\WebformInterface|null $webform: A webform.
\Drupal\webform\WebformSubmissionInterface|null $webform_submission: A webform submission.
Return value
array A render array representing a webform confirmation page
2 string references to 'WebformEntityController::confirmation'
- webform.routing.yml in ./
webform.routing.yml - webform.routing.yml
- webform_node.routing.yml in modules/
webform_node/ webform_node.routing.yml - modules/webform_node/webform_node.routing.yml
File
- src/
Controller/ WebformEntityController.php, line 154
Class
- WebformEntityController
- Provides route responses for Webform entity.
Namespace
Drupal\webform\ControllerCode
public function confirmation(Request $request, WebformInterface $webform = NULL, WebformSubmissionInterface $webform_submission = NULL) {
/** @var \Drupal\Core\Entity\EntityInterface $source_entity */
if (!$webform) {
list($webform, $source_entity) = $this->requestHandler
->getWebformEntities();
}
else {
$source_entity = $this->requestHandler
->getCurrentSourceEntity('webform');
}
if ($token = $request
->get('token')) {
/** @var \Drupal\webform\WebformSubmissionStorageInterface $webform_submission_storage */
$webform_submission_storage = $this
->entityTypeManager()
->getStorage('webform_submission');
if ($entities = $webform_submission_storage
->loadByProperties([
'token' => $token,
])) {
$webform_submission = reset($entities);
}
}
// Alter webform settings before setting the entity.
if ($webform_submission) {
$webform_submission
->getWebform()
->invokeHandlers('overrideSettings', $webform_submission);
}
// Apply variants.
if ($webform
->hasVariants()) {
if ($webform_submission) {
$webform
->applyVariants($webform_submission);
}
else {
$variants = $this
->getVariants($request, $webform, $source_entity);
$webform
->applyVariants(NULL, $variants);
}
}
// Get title.
$title = $webform
->getSetting('confirmation_title') ?: ($source_entity ? $source_entity
->label() : $webform
->label());
// Replace tokens in title.
$title = $this->tokenManager
->replace($title, $webform_submission ?: $webform);
$build = [
'#title' => $title,
'#theme' => 'webform_confirmation',
'#webform' => $webform,
'#source_entity' => $source_entity,
'#webform_submission' => $webform_submission,
];
// Add entities cacheable dependency.
$this->renderer
->addCacheableDependency($build, $webform);
if ($webform_submission) {
$this->renderer
->addCacheableDependency($build, $webform_submission);
}
if ($source_entity) {
$this->renderer
->addCacheableDependency($build, $source_entity);
}
return $build;
}