Skip to content

Commit

Permalink
[!!!][TASK] Mitigate depecated flash message severity
Browse files Browse the repository at this point in the history
Since TYPO3 v12 the flash message severity are deprecated in favour of
the `ContextualFeedbackSeverity` and will fail in TYPO3 v13.

This change mitigates the deprecation and removal by directly using the
native PHP Enum for TYPO3 v12 and TYPO3 v13 by:

* Changing signature of `AbstractTranslateHook::flashMessages()` from
  integer to `ContextualFeedbackSeverity`.
* Replace integer `-1` with `ContextualFeedbackSeverity::INFO` in two
  places within `TranslateHook`. Something addon extensions needs to
  handle on their own.

[1] https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Deprecation-97787-SeveritiesOfFlashMessagesAndReportsDeprecated.html
  • Loading branch information
sbuerk committed Dec 19, 2024
1 parent f71cf02 commit 099d3c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Classes/Hooks/AbstractTranslateHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use WebVision\Deepltranslate\Core\Domain\Dto\TranslateContext;
use WebVision\Deepltranslate\Core\Domain\Repository\PageRepository;
Expand Down Expand Up @@ -98,7 +99,7 @@ protected function findCurrentParentPage(string $tableName, int $currentRecordId
return $pageId;
}

protected function flashMessages(string $message, string $title, int $severity): void
protected function flashMessages(string $message, string $title, ContextualFeedbackSeverity $severity): void
{
if (Environment::isCli() || Environment::getContext()->isTesting()) {
return;
Expand Down
5 changes: 3 additions & 2 deletions Classes/Hooks/TranslateHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use WebVision\Deepltranslate\Core\Exception\LanguageIsoCodeNotFoundException;
use WebVision\Deepltranslate\Core\Exception\LanguageRecordNotFoundException;
Expand Down Expand Up @@ -65,14 +66,14 @@ public function processTranslateTo_copyAction(
$this->flashMessages(
'Translation not successful', // ToDo use locallang label
'',
-1
ContextualFeedbackSeverity::INFO
);
}
} catch (LanguageIsoCodeNotFoundException|LanguageRecordNotFoundException $e) {
$this->flashMessages(
$e->getMessage(),
'',
-1 // Info
ContextualFeedbackSeverity::INFO
);
}

Expand Down

0 comments on commit 099d3c8

Please sign in to comment.