‪TYPO3CMS  ‪main
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 
26 
31 {
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->getLocale()->getLanguageCode();
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->getLocale()->getLanguageCode(),
77  $languageId
78  );
79  $flashMessage = GeneralUtility::makeInstance(
80  FlashMessage::class,
81  $message,
82  '',
83  ContextualFeedbackSeverity::ERROR
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 
95  {
96  return ‪$GLOBALS['LANG'];
97  }
98 
100  {
101  return ‪$GLOBALS['BE_USER'];
102  }
103 }
‪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
‪$languages
‪$languages
Definition: updateIsoDatabase.php:104
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseSystemLanguageRows\getLanguageService
‪getLanguageService()
Definition: DatabaseSystemLanguageRows.php:94
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseSystemLanguageRows\getBackendUser
‪getBackendUser()
Definition: DatabaseSystemLanguageRows.php:99
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseSystemLanguageRows
Definition: DatabaseSystemLanguageRows.php:31
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Messaging\FlashMessageService
Definition: FlashMessageService.php:27