Skip to content

Commit

Permalink
[TASK] Make glossary sync more tolerant of outdated IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
koehnlein authored and calien666 committed Apr 28, 2023
1 parent 5dd4942 commit 3a8587c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Classes/Service/DeeplGlossaryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

namespace WebVision\WvDeepltranslate\Service;

use GuzzleHttp\Exception\BadResponseException;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use WebVision\WvDeepltranslate\Exception\GlossaryEntriesNotExistException;
use WebVision\WvDeepltranslate\Service\Client\Client;
Expand Down Expand Up @@ -157,7 +160,21 @@ public function deleteGlossary(string $glossaryId)
$url = $this->client->buildBaseUrl(self::API_URL_SUFFIX_GLOSSARIES);
$url .= "/$glossaryId";

$this->client->request($url, '', 'DELETE');
try {
$this->client->request($url, '', 'DELETE');
} catch (BadResponseException $e) {
// FlashMessage($message, $title, $severity = self::OK, $storeInSession)
$message = GeneralUtility::makeInstance(
FlashMessage::class,
$e->getMessage(),
'DeepL Api',
FlashMessage::WARNING,
true
);
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$messageQueue = $flashMessageService->getMessageQueueByIdentifier();
$messageQueue->addMessage($message);
}
}

/**
Expand Down

0 comments on commit 3a8587c

Please sign in to comment.