public function WebformSubmissionViewController::view in Webform 8.5
Same name and namespace in other branches
- 6.x src/Controller/WebformSubmissionViewController.php \Drupal\webform\Controller\WebformSubmissionViewController::view()
Provides a page to render a single entity.
Parameters
\Drupal\Core\Entity\EntityInterface $_entity: The Entity to be rendered. Note this variable is named $_entity rather than $entity to prevent collisions with other named placeholders in the route.
string $view_mode: (optional) The view mode that should be used to display the entity. Defaults to 'full'.
Return value
array A render array as expected by \Drupal\Core\Render\RendererInterface::render().
Overrides EntityViewController::view
2 string references to 'WebformSubmissionViewController::view'
- 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/ WebformSubmissionViewController.php, line 68
Class
- WebformSubmissionViewController
- Defines a controller to render a single webform submission.
Namespace
Drupal\webform\ControllerCode
public function view(EntityInterface $webform_submission, $view_mode = 'default', $langcode = NULL) {
$webform = $this->requestHandler
->getCurrentWebform();
$source_entity = $this->requestHandler
->getCurrentSourceEntity('webform_submission');
// Set webform submission template.
$build = [
'#theme' => 'webform_submission',
'#view_mode' => $view_mode,
'#webform_submission' => $webform_submission,
];
// Navigation.
$build['navigation'] = [
'#type' => 'webform_submission_navigation',
'#webform_submission' => $webform_submission,
];
// Information.
$build['information'] = [
'#type' => 'webform_submission_information',
'#webform_submission' => $webform_submission,
'#source_entity' => $source_entity,
];
// Submission.
$build['submission'] = parent::view($webform_submission, $view_mode, $langcode);
// Library.
$build['#attached']['library'][] = 'webform/webform.admin';
// Add entities cacheable dependency.
$this->renderer
->addCacheableDependency($build, $this->currentUser);
$this->renderer
->addCacheableDependency($build, $webform);
$this->renderer
->addCacheableDependency($build, $webform_submission);
if ($source_entity) {
$this->renderer
->addCacheableDependency($build, $source_entity);
}
return $build;
}