From 6d3c86d7e89e3e5e53bb109a12c9535519aa44b8 Mon Sep 17 00:00:00 2001
From: Marcus Johansson <me@marcusmailbox.com>
Date: Mon, 18 Nov 2024 18:03:48 +0100
Subject: [PATCH] Issue #3488220: Make an event to be able to change the guzzle
 client

---
 src/Base/AiProviderClientBase.php     | 2 +-
 src/Event/HttpClientCreationEvent.php | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Base/AiProviderClientBase.php b/src/Base/AiProviderClientBase.php
index 633efa305..08a6b0dac 100644
--- a/src/Base/AiProviderClientBase.php
+++ b/src/Base/AiProviderClientBase.php
@@ -202,7 +202,7 @@ abstract class AiProviderClientBase implements AiProviderInterface, ContainerFac
     $this->eventDispatcher = $event_dispatcher;
     $this->pluginDefinition = $plugin_definition;
     $this->pluginId = $plugin_id;
-    $this->httpClient = $this->getHttpClient();
+    $this->httpClient = $this->getHttpClient() ?? $http_client;
     $this->configFactory = $config_factory;
     $this->loggerFactory = $logger_factory;
     $this->moduleHandler = $module_handler;
diff --git a/src/Event/HttpClientCreationEvent.php b/src/Event/HttpClientCreationEvent.php
index fe6b9ee18..7308df28c 100644
--- a/src/Event/HttpClientCreationEvent.php
+++ b/src/Event/HttpClientCreationEvent.php
@@ -20,14 +20,14 @@ class HttpClientCreationEvent extends Event {
   protected $providerId;
 
   /**
-   * The (optional) operation type for the request.
+   * The (optional) operation type for the client.
    *
    * @var string
    */
   protected $operationType = '';
 
   /**
-   * The (optional) model ID for the request.
+   * The (optional) model ID for the client.
    *
    * @var string
    */
@@ -48,9 +48,9 @@ class HttpClientCreationEvent extends Event {
    * @param array $configuration
    *   The configuration for the client.
    * @param string $operation_type
-   *   The operation type for the request.
+   *   The operation type for the client.
    * @param string $model_id
-   *   The model ID for the request.
+   *   The model ID for the client.
    */
   public function __construct(string $provider_id, array $configuration, string $operation_type, string $model_id) {
     $this->providerId = $provider_id;
-- 
GitLab