You are here

function webform_entity_print_webform_submission_view_alter in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_entity_print/webform_entity_print.module \webform_entity_print_webform_submission_view_alter()

Implements hook_ENTITY_TYPE_view_alter() for webform_submission entities.

See also

entity_print_entity_view_alter();

File

modules/webform_entity_print/webform_entity_print.module, line 63
Provides Entity Print (PDF) integration.

Code

function webform_entity_print_webform_submission_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
  $route_name = \Drupal::routeMatch()
    ->getRouteName();
  $is_entity_print = in_array($route_name, [
    'entity_print.view.debug',
    'entity_print.view',
  ]) || \Drupal::request()->request
    ->get('_webform_entity_print');
  if ($is_entity_print) {

    // Add template header and footer.
    _webform_entity_print_webform_submission_template($build, $entity, $display);
  }
  elseif (in_array($display
    ->getMode(), [
    'html',
    'table',
  ])) {

    // Add print links to HTML and Table mode.
    _webform_entity_print_webform_submission_links($build, $entity, $display);
  }
}