‪TYPO3CMS  11.5
TcaColumnsProcessFieldDescriptions.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 
29 {
36  public function ‪addData(array $result): array
37  {
38  $result = $this->‪setDescriptionFromPageTsConfig($result);
39  $result = $this->‪translateDescriptions($result);
40  return $result;
41  }
42 
52  protected function ‪setDescriptionFromPageTsConfig(array $result): array
53  {
54  $languageService = $this->‪getLanguageService();
55  $tableName = $result['tableName'];
56  foreach ($result['processedTca']['columns'] ?? [] as $fieldName => $fieldConfiguration) {
57  $fieldTSconfig = $result['pageTsConfig']['TCEFORM.'][$tableName . '.'][$fieldName . '.'] ?? null;
58  if (!is_array($fieldTSconfig)) {
59  continue;
60  }
61  if (!empty($fieldTSconfig['description'])) {
62  $result['processedTca']['columns'][$fieldName]['description'] = $fieldTSconfig['description'];
63  }
64  if (!empty($fieldTSconfig['description.'][$languageService->lang])) {
65  $result['processedTca']['columns'][$fieldName]['description'] = $fieldTSconfig['description.'][$languageService->lang];
66  }
67  }
68  return $result;
69  }
70 
77  protected function ‪translateDescriptions(array $result): array
78  {
79  $languageService = $this->‪getLanguageService();
80  foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfiguration) {
81  if (!isset($fieldConfiguration['description'])) {
82  continue;
83  }
84  $result['processedTca']['columns'][$fieldName]['description'] = $languageService->sL($fieldConfiguration['description']);
85  }
86  return $result;
87  }
88 
93  {
94  return ‪$GLOBALS['LANG'];
95  }
96 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessFieldDescriptions\setDescriptionFromPageTsConfig
‪array setDescriptionFromPageTsConfig(array $result)
Definition: TcaColumnsProcessFieldDescriptions.php:52
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessFieldDescriptions
Definition: TcaColumnsProcessFieldDescriptions.php:29
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessFieldDescriptions\addData
‪array addData(array $result)
Definition: TcaColumnsProcessFieldDescriptions.php:36
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessFieldDescriptions\getLanguageService
‪LanguageService getLanguageService()
Definition: TcaColumnsProcessFieldDescriptions.php:92
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessFieldDescriptions\translateDescriptions
‪array translateDescriptions(array $result)
Definition: TcaColumnsProcessFieldDescriptions.php:77