From 4cbc91788d2a6ea8269e80044d17399f1ae1f605 Mon Sep 17 00:00:00 2001 From: Rafal Jania Date: Tue, 2 Apr 2024 14:19:23 +0200 Subject: [PATCH 1/2] [BUGFIX] Configuration - Request in ext:Form Preview Mode --- Classes/Configuration.php | 3 ++- Classes/ViewHelpers/ConfigurationViewHelper.php | 8 ++++++-- ext_emconf.php | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Classes/Configuration.php b/Classes/Configuration.php index 7d250d7..3b52193 100644 --- a/Classes/Configuration.php +++ b/Classes/Configuration.php @@ -4,6 +4,7 @@ namespace StudioMitte\FriendlyCaptcha; +use TYPO3\CMS\Core\Site\Entity\NullSite; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Site\Entity\Site; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -24,7 +25,7 @@ public function __construct(Site $site = null) if ($site === null) { $site = $GLOBALS['TYPO3_REQUEST']->getAttribute('site'); } - if ($site === null) { + if ($site === null || $site instanceof NullSite) { return; } $siteConfiguration = $site->getConfiguration(); diff --git a/Classes/ViewHelpers/ConfigurationViewHelper.php b/Classes/ViewHelpers/ConfigurationViewHelper.php index 66e3854..a9ef545 100644 --- a/Classes/ViewHelpers/ConfigurationViewHelper.php +++ b/Classes/ViewHelpers/ConfigurationViewHelper.php @@ -29,9 +29,13 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl protected static function getLanguageIsoCode(): string { + $language = $GLOBALS['TYPO3_REQUEST']->getAttribute('language'); + if(!$language) { + return ''; + } if ((new Typo3Version())->getMajorVersion() >= 12) { - return $GLOBALS['TYPO3_REQUEST']->getAttribute('language')->getLocale()->getLanguageCode(); + return $language->getLocale()->getLanguageCode(); } - return $GLOBALS['TYPO3_REQUEST']->getAttribute('language')->getTwoLetterIsoCode(); + return $language->getTwoLetterIsoCode(); } } diff --git a/ext_emconf.php b/ext_emconf.php index d50046a..8111848 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -17,5 +17,5 @@ ], ], 'state' => 'beta', - 'version' => '0.1.2', + 'version' => '0.1.3', ]; From f51826ce246152565caa5a6aa5e1a8e420bf483e Mon Sep 17 00:00:00 2001 From: Rafal Jania Date: Tue, 2 Apr 2024 14:23:28 +0200 Subject: [PATCH 2/2] Run csfix - fix pipeline --- Classes/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Configuration.php b/Classes/Configuration.php index 3b52193..22eac13 100644 --- a/Classes/Configuration.php +++ b/Classes/Configuration.php @@ -4,8 +4,8 @@ namespace StudioMitte\FriendlyCaptcha; -use TYPO3\CMS\Core\Site\Entity\NullSite; use TYPO3\CMS\Core\Core\Environment; +use TYPO3\CMS\Core\Site\Entity\NullSite; use TYPO3\CMS\Core\Site\Entity\Site; use TYPO3\CMS\Core\Utility\GeneralUtility;