Skip to content

Commit

Permalink
[BUGFIX] Use TYPO3 http client
Browse files Browse the repository at this point in the history
Since all $GLOBALS['TYPO3_CONF_VARS']['HTTP'] options should be
respected we can simple use the built in client. Also 'proxy'
is respected in this case, so we don't need a extra setting for this.

Resolves: web-vision#370
Relates: web-vision#331
  • Loading branch information
Mabahe committed Oct 22, 2024
1 parent cfca941 commit 86401f1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Classes/AbstractClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace WebVision\WvDeepltranslate;

use DeepL\Translator;
use DeepL\TranslatorOptions;
use Psr\Log\LoggerInterface;
use TYPO3\CMS\Core\Http\Client\GuzzleClientFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use WebVision\WvDeepltranslate\Exception\ApiKeyNotSetException;

Expand Down Expand Up @@ -42,8 +44,8 @@ protected function getTranslator(): Translator
if ($this->configuration->getApiKey() === '') {
throw new ApiKeyNotSetException('The api key ist not set', 1708081233823);
}

$this->translator = GeneralUtility::makeInstance(Translator::class, $this->configuration->getApiKey());
$options[TranslatorOptions::HTTP_CLIENT] = GeneralUtility::makeInstance(GuzzleClientFactory::class)->getClient();
$this->translator = GeneralUtility::makeInstance(Translator::class, $this->configuration->getApiKey(), $options);

return $this->translator;
}
Expand Down

0 comments on commit 86401f1

Please sign in to comment.