Skip to content

Commit

Permalink
[BUGFIX] Use TYPO3 configured proxy for deepl client
Browse files Browse the repository at this point in the history
When converting the client, the proxy configuration via TYPO3 was no longer taken into account.
This will be made up for with this change.
  • Loading branch information
NarkNiro committed May 22, 2024
1 parent cfca941 commit a8e9918
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Classes/AbstractClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace WebVision\WvDeepltranslate;

use DeepL\Translator;
use DeepL\TranslatorOptions;
use Psr\Log\LoggerInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use WebVision\WvDeepltranslate\Exception\ApiKeyNotSetException;
Expand Down Expand Up @@ -43,7 +44,14 @@ protected function getTranslator(): Translator
throw new ApiKeyNotSetException('The api key ist not set', 1708081233823);
}

$this->translator = GeneralUtility::makeInstance(Translator::class, $this->configuration->getApiKey());
$options = [];
if (isset($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy']) && $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy'] !== '') {
if (GeneralUtility::isValidUrl($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy'])) {
$options[TranslatorOptions::PROXY] = $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy'];
}
}

$this->translator = new Translator($this->configuration->getApiKey(), $options);

return $this->translator;
}
Expand Down

0 comments on commit a8e9918

Please sign in to comment.