Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miloskroulik/bf62bd283f51ae16d188eb5cc3d47932 to your computer and use it in GitHub Desktop.
Save miloskroulik/bf62bd283f51ae16d188eb5cc3d47932 to your computer and use it in GitHub Desktop.
/**
* Implements hook_entity_operation_alter().
*/
function hd_entity_print_uuid_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity)
{
if ($entity->getEntityTypeId() === 'webform_submission') {
$operations['pdf_download']['title'] = t('Download PDF');
$route_params = [
'entity_type' => $entity->getEntityTypeId(),
'entity_id' => $entity->id(),
// This should not be hardcoded
'export_type' => 'pdf',
];
$view_mode = 'html';
$route_options = ['query' => ['view_mode' => $view_mode]];
$operations['pdf_download']['url'] = \Drupal\Core\Url::fromRoute('entity_print.view', $route_params, $route_options);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment