- Issue created by @jessehs
I have a node page that includes views in the twig template that are printed using twig_tweak. Ex:
{{ drupal_block('views_block:my_custom_view-block_1') }}
These views use a contextual filter "Content ID" (nid), which is configured to use a default argument "Content ID from URL". This works fine when viewing the node page, but when I view the entity print url, "print/pdf/node/123/debug", the default argument does not work.
Drupal normally uses route parameters to get the current node. The views code in question uses:
// \Drupal\node\Plugin\views\argument_default\Node::getArgument
$node = $this->routeMatch->getParameter('node')
The entity print routing includes parameters "entity_type" and "entity_id", but not node. One way to get node is to decorate the current_route_match service so that the node parameter can be added to the available parameters.
The attached patch is a first attempt at this, which adds support for "node". This could be extended to also include other entity types, but this solves my use case for now.
Active
2.0
Code