[TASK] Remove leftover code from PseudoSite Handling 43/60843/2
authorBenni Mack <benni@typo3.org>
Wed, 29 May 2019 21:15:06 +0000 (23:15 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 3 Jun 2019 10:06:13 +0000 (12:06 +0200)
The SiteMatcher object now always returns a Site / NullSite, so there
will never be an exception "SiteNotFoundException" thrown.

This dead code, which is never executed, can be removed.

Resolves: #88461
Releases: master
Change-Id: I458b46f3beea2ea7934a4557acac67453a819784
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60843
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/backend/Classes/Configuration/TranslationConfigurationProvider.php

index 8d1039c..649ff1f 100644 (file)
@@ -20,10 +20,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
-use TYPO3\CMS\Core\Exception\SiteNotFoundException;
-use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Routing\SiteMatcher;
-use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -34,15 +31,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 class TranslationConfigurationProvider
 {
     /**
-     * @return LanguageService
-     */
-    protected function getLanguageService()
-    {
-        return $GLOBALS['LANG'];
-    }
-
-    /**
-     * Returns array of system languages
+     * Returns array of languages given for a specific site (or "nullSite" if on page=0)
      * The property flagIcon returns a string <flags-xx>.
      *
      * @param int $pageId Page id (used to get TSconfig configuration setting flag and label for default language)
@@ -50,62 +39,18 @@ class TranslationConfigurationProvider
      */
     public function getSystemLanguages($pageId = 0)
     {
-        try {
-            $siteMatcher = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId((int)$pageId);
-            $siteLanguages = $siteMatcher->getAvailableLanguages($this->getBackendUserAuthentication(), true);
+        $siteMatcher = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId((int)$pageId);
+        $siteLanguages = $siteMatcher->getAvailableLanguages($this->getBackendUserAuthentication(), true);
 
-            $languages = [];
-            foreach ($siteLanguages as $id => $siteLanguage) {
-                $languages[$id] = [
-                    'uid' => $id,
-                    'title' => $siteLanguage->getTitle(),
-                    'ISOcode' => $siteLanguage->getTwoLetterIsoCode(),
-                    'flagIcon' => $siteLanguage->getFlagIdentifier(),
-                ];
-            }
-        } catch (SiteNotFoundException $e) {
-            // default language and "all languages" are always present
-            $modSharedTSconfig = BackendUtility::getPagesTSconfig($pageId)['mod.']['SHARED.'] ?? [];
-            $languages = [
-                // 0: default language
-                0 => [
-                    'uid' => 0,
-                    'title' => $this->getDefaultLanguageLabel($modSharedTSconfig),
-                    'ISOcode' => 'DEF',
-                    'flagIcon' => $this->getDefaultLanguageFlag($modSharedTSconfig),
-                ],
-                // -1: all languages
-                -1 => [
-                    'uid' => -1,
-                    'title' => $this->getLanguageService()->getLL('multipleLanguages'),
-                    'ISOcode' => 'DEF',
-                    'flagIcon' => 'flags-multiple',
-                ],
+        $languages = [];
+        foreach ($siteLanguages as $id => $siteLanguage) {
+            $languages[$id] = [
+                'uid' => $id,
+                'title' => $siteLanguage->getTitle(),
+                'ISOcode' => $siteLanguage->getTwoLetterIsoCode(),
+                'flagIcon' => $siteLanguage->getFlagIdentifier(),
             ];
-
-            // add the additional languages from database records
-            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_language');
-            $languageRecords = $queryBuilder
-                ->select('*')
-                ->from('sys_language')
-                ->orderBy('sorting')
-                ->execute()
-                ->fetchAll();
-            foreach ($languageRecords as $languageRecord) {
-                $languages[$languageRecord['uid']] = $languageRecord;
-                // @todo: this should probably resolve language_isocode too and throw a deprecation if not filled
-                if ($languageRecord['static_lang_isocode'] && ExtensionManagementUtility::isLoaded('static_info_tables')) {
-                    $staticLangRow = BackendUtility::getRecord('static_languages', $languageRecord['static_lang_isocode'], 'lg_iso_2');
-                    if ($staticLangRow['lg_iso_2']) {
-                        $languages[$languageRecord['uid']]['ISOcode'] = $staticLangRow['lg_iso_2'];
-                    }
-                }
-                if ($languageRecord['flag'] !== '') {
-                    $languages[$languageRecord['uid']]['flagIcon'] = 'flags-' . $languageRecord['flag'];
-                }
-            }
         }
-
         return $languages;
     }
 
@@ -204,34 +149,6 @@ class TranslationConfigurationProvider
         ];
     }
 
-    /**
-     * @param array $modSharedTSconfig
-     * @return string
-     */
-    protected function getDefaultLanguageFlag(array $modSharedTSconfig)
-    {
-        if (strlen($modSharedTSconfig['defaultLanguageFlag'])) {
-            $defaultLanguageFlag = 'flags-' . $modSharedTSconfig['defaultLanguageFlag'];
-        } else {
-            $defaultLanguageFlag = 'empty-empty';
-        }
-        return $defaultLanguageFlag;
-    }
-
-    /**
-     * @param array $modSharedTSconfig
-     * @return string
-     */
-    protected function getDefaultLanguageLabel(array $modSharedTSconfig)
-    {
-        if (strlen($modSharedTSconfig['defaultLanguageLabel'])) {
-            $defaultLanguageLabel = $modSharedTSconfig['defaultLanguageLabel'] . ' (' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage') . ')';
-        } else {
-            $defaultLanguageLabel = $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage');
-        }
-        return $defaultLanguageLabel;
-    }
-
     protected function getBackendUserAuthentication(): BackendUserAuthentication
     {
         return $GLOBALS['BE_USER'];