Skip to content

Commit

Permalink
[!!!][FEATURE] Provide dedicated enum for contextual feedback
Browse files Browse the repository at this point in the history
To clean up cluttered severity definitions for flash messages and
reports, a new `ContextualFeedback` enum is introduced.

The enum is backed, means it holds actual values, which match the
previously known integer values for severities. An internal
`transform()` method may be used to maintain backward compatibility
where needed and to trigger deprecation notices.

Resolves: #97787
Releases: main
Change-Id: I44b706c929277bc765bf302b2b1d32aa1da31f85
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74925
Tested-by: core-ci <[email protected]>
Tested-by: Frank Nägler <[email protected]>
Tested-by: Benni Mack <[email protected]>
Tested-by: Andreas Fernandez <[email protected]>
Reviewed-by: Frank Nägler <[email protected]>
Reviewed-by: Markus Klein <[email protected]>
Reviewed-by: Oliver Klee <[email protected]>
Reviewed-by: Andreas Fernandez <[email protected]>
  • Loading branch information
andreaskienast committed Jul 14, 2022
1 parent 43df5cc commit 75ea219
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Classes/Task/CleanerFieldProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace TYPO3\CMS\Recycler\Task;

use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
use TYPO3\CMS\Scheduler\Task\AbstractTask;
Expand Down Expand Up @@ -132,7 +132,7 @@ protected function checkTcaIsNotEmpty($tca)
} else {
$this->addMessage(
$this->getLanguageService()->sL('LLL:EXT:recycler/Resources/Private/Language/locallang_tasks.xlf:cleanerTaskErrorTCAempty'),
FlashMessage::ERROR
ContextualFeedbackSeverity::ERROR
);
$validTca = false;
}
Expand All @@ -154,7 +154,7 @@ protected function checkTcaIsValid(array $tca)
$checkTca = false;
$this->addMessage(
sprintf($this->getLanguageService()->sL('LLL:EXT:recycler/Resources/Private/Language/locallang_tasks.xlf:cleanerTaskErrorTCANotSet'), $tcaTable),
FlashMessage::ERROR
ContextualFeedbackSeverity::ERROR
);
break;
}
Expand All @@ -177,7 +177,7 @@ protected function validateAdditionalFieldPeriod($period)
} else {
$this->addMessage(
$this->getLanguageService()->sL('LLL:EXT:recycler/Resources/Private/Language/locallang_tasks.xlf:cleanerTaskErrorPeriod'),
FlashMessage::ERROR
ContextualFeedbackSeverity::ERROR
);
$validPeriod = false;
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Task/CleanerFieldProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Recycler\Task\CleanerFieldProvider;
use TYPO3\CMS\Recycler\Task\CleanerTask;
use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
Expand Down Expand Up @@ -104,7 +104,7 @@ public function validateAdditionalFieldsLogsPeriodError($period): void
$scheduleModuleControllerMock = $this->getScheduleModuleControllerMock();
$this->subject->expects(self::atLeastOnce())
->method('addMessage')
->with(self::equalTo('titleTest'), FlashMessage::ERROR);
->with(self::equalTo('titleTest'), ContextualFeedbackSeverity::ERROR);

$this->subject->validateAdditionalFields($submittedData, $scheduleModuleControllerMock);
}
Expand Down

0 comments on commit 75ea219

Please sign in to comment.