In Drupal Development Service previous there have been some hooks, akin to described right here: The way to run test on every web page load?
to execute arbitrary code on every web page load.
Now this has been changed with an occasion primarily based strategy. I wrote this to test it out:
class MyModuleEventSubscriber implements EventSubscriberInterface { public perform onLoad(GetResponseEvent $occasion) { Drupal::logger('my_module')->information('check'); } /** * {@inheritdoc} */ public static perform getSubscribedEvents() { $occasions[KernelEvents::REQUEST][] = ['onLoad']; return $occasions; } }
Nonetheless, it looks like there may be any variety of requests on every web page load—it really captures every request, and in my case there are 5 (5). My meant code, nevertheless, has to name an out of doors API, and I would wish to keep away from pointless calls.
Is there an occasion that’s assured to run simply as soon as on every web page load, with out saving a state on my aspect (that appears fairly difficult for this drawback)?