Load the API kernel service prior to dispatching the `civi.api4.createRequest` event...
authorJens Schuppe <schuppe@systopia.de>
Fri, 15 Oct 2021 12:23:51 +0000 (14:23 +0200)
committerJens Schuppe <schuppe@systopia.de>
Fri, 15 Oct 2021 12:23:51 +0000 (14:23 +0200)
Civi/API/Request.php

index 4c9a6d5fc0a9418eb6a97d8ec3f1199017c36256..65d5c280353b9d76edf2f281a988edf7de9bdade 100644 (file)
@@ -45,6 +45,10 @@ class Request {
         ];
 
       case 4:
+        // Load the API kernel service for registering API providers, as
+        // otherwise subscribers to the civi.api4.createRequest event registered
+        // through the EventSubscriberInterface will not be registered.
+        $kernel = \Civi::service('civi_api_kernel');
         $e = new CreateApi4RequestEvent($entity);
         \Civi::dispatcher()->dispatch('civi.api4.createRequest', $e);
         $callable = [$e->className, $action];