Global preprocess for all links Is there a some sort of global preprocessing hook for any link on a Drupal site?

Use case:

I've got an enquiry webform embedded on a node that presets some inputs by URL parameters. Editors can set links to that enquiry node on multiple different places on the site (in navigation menus, inside text fields using LinkIt, in URL fields,...). 

Whenever the currently active context is a certain node type (e.g. on every full view of a product like "/product/product-id"), I want all links that are rendered on the page (e.g. menu links, blocks, entity reference field on the product pointing to the enquiry node, etc) to have the product_id appended.

I know how to get the current node id in preprocessing and I do know hook_link_alter for menus. But I wonder if there is some sort of global hook that captures all links, saving me from creating 453 different hooks doing all the same thing.
One way to accomplish this would be by using a service tagged with the path_processor_outbound service tag.
Your service should then implement the processOutbound() function in order to modify all links on a page, if the request delivers a node object of the type you want.

This is an example service definition using the described service tag:

services:
  dummy.link_modifier_service:
    class: Drupal\dummy\DefaultService
    tags:
      - { name: path_processor_outbound }
    arguments: ['@request_stack']


This is an example implementation of such a service:

&lt;?php

namespace Drupal\dummy;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Render\BubbleableMetadata;

/**
 * Class DefaultService.
 */
class DefaultService implements DefaultServiceInterface, OutboundPathProcessorInterface {

  /**
   * Symfony\Component\HttpFoundation\RequestStack definition.
   *
   * @var \Symfony\Component\HttpFoundation\RequestStack
   */
  protected $requestStack;
  /**
   * Constructs a new DefaultService object.
   */
  public function __construct(RequestStack $request_stack) {
    $this-&gt;requestStack = $request_stack;
  }

  /**
   * {@inheritdoc}
   */
  public function processOutbound($path, &amp;$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {

    if (empty($request)) {
      $request = $this-&gt;requestStack-&gt;getCurrentRequest();
    }
    $node = $request-&gt;attributes-&gt;get('node');
    if ($node &amp;&amp; $node-&gt;bundle() === 'product') {
      $options['query'][] = [$node-&gt;bundle() . '_id' =&gt; $node-&gt;id()];
    }
    return $path;
  }  

}


This code will now be modifying all Drupal-handled URLs and adding a product_id=XX parameter to them.

Hope this helps, good luck! 

@see https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21PathProcessor%21OutboundPathProcessorInterface.php/function/OutboundPathProcessorInterface%3A%3AprocessOutbound/