‪TYPO3CMS  11.5
DatabaseSystemLanguageRows.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
25 
30 {
38  public function ‪addData(array $result)
39  {
40  $site = $result['site'] ?? null;
41  if (!$site instanceof ‪SiteInterface) {
42  throw new \LogicException(
43  'No valid site object found in $result[\'site\']',
44  1534952559
45  );
46  }
47  $pageIdDefaultLanguage = $result['defaultLanguagePageRow']['uid'] ?? $result['effectivePid'];
48  $languages = $site->getAvailableLanguages($this->‪getBackendUser(), true, $pageIdDefaultLanguage);
49 
50  $languageRows = [];
51  foreach ($languages as $language) {
52  $languageId = $language->getLanguageId();
53  if ($languageId > 0) {
54  $iso = $language->getTwoLetterIsoCode();
55  } else {
56  $iso = 'DEF';
57  }
58  $languageRows[$languageId] = [
59  'uid' => $languageId,
60  'title' => $language->getTitle(),
61  'iso' => $iso,
62  'flagIconIdentifier' => $language->getFlagIdentifier(),
63  ];
64 
65  if (empty($iso)) {
66  // No iso code could be found. This is currently possible in the system but discouraged.
67  // So, code within FormEngine has to be suited to work with an empty iso code. However,
68  // it may impact certain multi language scenarios, so we add a flash message hinting for
69  // incomplete configuration here.
70  // It might be possible to convert this to a non-catchable exception later if
71  // it iso code is enforced on a different layer of the system (tca required + migration wizard).
72  // @todo: This could be relaxed again if flex form language handling is extracted,
73  // @todo: since the rest of the FormEngine code does not rely on iso code?
74  $message = sprintf(
75  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:error.missingLanguageIsocode'),
76  $language->getTwoLetterIsoCode(),
77  $languageId
78  );
79  $flashMessage = GeneralUtility::makeInstance(
80  FlashMessage::class,
81  $message,
82  '',
84  );
85  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
86  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
87  $defaultFlashMessageQueue->enqueue($flashMessage);
88  }
89  }
90  $result['systemLanguageRows'] = $languageRows;
91  return $result;
92  }
93 
98  {
99  return ‪$GLOBALS['LANG'];
100  }
101 
106  {
107  return ‪$GLOBALS['BE_USER'];
108  }
109 }
‪TYPO3\CMS\Core\Site\Entity\SiteInterface
Definition: SiteInterface.php:26
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseSystemLanguageRows\addData
‪array addData(array $result)
Definition: DatabaseSystemLanguageRows.php:38
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseSystemLanguageRows\getBackendUser
‪BackendUserAuthentication getBackendUser()
Definition: DatabaseSystemLanguageRows.php:105
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseSystemLanguageRows\getLanguageService
‪LanguageService getLanguageService()
Definition: DatabaseSystemLanguageRows.php:97
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:26
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseSystemLanguageRows
Definition: DatabaseSystemLanguageRows.php:30
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Messaging\FlashMessageService
Definition: FlashMessageService.php:27
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:31