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