From 77fe3d15fd0366987e23cc6fcd8b5987f14f3671 Mon Sep 17 00:00:00 2001 From: Georgi Mateev <gmateev@exactag.com> Date: Fri, 13 Aug 2021 17:16:23 +0300 Subject: [PATCH] [BUGFIX] Fixed the Flash messages for the license key check --- Classes/Controller/RouteController.php | 57 ++++++++++---------------- 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/Classes/Controller/RouteController.php b/Classes/Controller/RouteController.php index 25bae80..466cc35 100644 --- a/Classes/Controller/RouteController.php +++ b/Classes/Controller/RouteController.php @@ -26,22 +26,19 @@ namespace SGalinski\SgRoutes\Controller; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use SGalinski\SgRoutes\Service\DemoModeService; use InvalidArgumentException; use SGalinski\SgRoutes\Domain\Model\Category; -use SGalinski\SgRoutes\Domain\Model\PageNotFoundHandling; use SGalinski\SgRoutes\Domain\Model\Route; use SGalinski\SgRoutes\Domain\Repository\CategoryRepository; use SGalinski\SgRoutes\Domain\Repository\LogRepository; use SGalinski\SgRoutes\Domain\Repository\PageNotFoundHandlingRepository; use SGalinski\SgRoutes\Domain\Repository\RoutehitRepository; use SGalinski\SgRoutes\Domain\Repository\RouteRepository; +use SGalinski\SgRoutes\Service\DemoModeService; use SGalinski\SgRoutes\Service\LicenceCheckService; use SGalinski\SgRoutes\Service\LicensingService; use SGalinski\SgRoutes\Service\RoutingService; use TYPO3\CMS\Backend\Clipboard\Clipboard; -use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException; -use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent; use TYPO3\CMS\Backend\Utility\BackendUtility; @@ -601,7 +598,6 @@ class RouteController extends ActionController { * Initializes the demo mode */ protected function initDemoMode() { - $typo3Version = VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version); $keyState = DemoModeService::checkKey(); $hasValidLicense = LicenceCheckService::hasValidLicense(); $isInDemoMode = DemoModeService::isInDemoMode(); @@ -616,16 +612,10 @@ class RouteController extends ActionController { LocalizationUtility::translate('backend.licenseKey.isInDemoMode.header', 'sg_routes'), AbstractMessage::INFO ); - } elseif ($keyState === DemoModeService::STATE_LICENSE_INVALID) { - if ($typo3Version < 9000000) { - $description = LocalizationUtility::translate( - 'backend.licenseKey.invalid.description', 'sg_routes' - ); - } else { - $description = LocalizationUtility::translate( - 'backend.licenseKey.invalid.descriptionTYPO3-9', 'sg_routes' - ); - } + } elseif (!$hasValidLicense) { + $description = LocalizationUtility::translate( + 'backend.licenseKey.invalid.descriptionTYPO3-9', 'sg_routes' + ); $this->addFlashMessage( $description, @@ -633,15 +623,9 @@ class RouteController extends ActionController { AbstractMessage::ERROR ); } elseif ($keyState === DemoModeService::STATE_LICENSE_NOT_SET) { - if ($typo3Version < 9000000) { - $description = LocalizationUtility::translate( - 'backend.licenseKey.notSet.description', 'sg_routes' - ); - } else { - $description = LocalizationUtility::translate( - 'backend.licenseKey.notSet.descriptionTYPO3-9', 'sg_routes' - ); - } + $description = LocalizationUtility::translate( + 'backend.licenseKey.notSet.descriptionTYPO3-9', 'sg_routes' + ); $this->addFlashMessage( $description, @@ -657,18 +641,19 @@ class RouteController extends ActionController { /** * Add a flash message * - * @param string $messageBody - * @param string $messageTitle - * @param int $severity - * @param bool $storeInSession - */ - public function addFlashMessage($messageBody, $messageTitle = '', $severity = AbstractMessage::OK, $storeInSession = true) - { - if (null === $this->controllerContext) { - $this->controllerContext = $this->buildControllerContext(); - } - parent::addFlashMessage($messageBody, $messageTitle, $severity, $storeInSession); - } + * @param string $messageBody + * @param string $messageTitle + * @param int $severity + * @param bool $storeInSession + */ + public function addFlashMessage( + $messageBody, $messageTitle = '', $severity = AbstractMessage::OK, $storeInSession = TRUE + ) { + if (NULL === $this->controllerContext) { + $this->controllerContext = $this->buildControllerContext(); + } + parent::addFlashMessage($messageBody, $messageTitle, $severity, $storeInSession); + } /** * Activates the demo mode for the given instance. -- GitLab