Created
October 13, 2023 07:41
-
-
Save miloskroulik/bf62bd283f51ae16d188eb5cc3d47932 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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