‪TYPO3CMS  ‪main
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  $pageTsConfigDescription = $languageService->translateLabel(
62  $fieldTSconfig['description.'] ?? [],
63  $fieldTSconfig['description'] ?? ''
64  );
65  if ($pageTsConfigDescription !== '') {
66  $result['processedTca']['columns'][$fieldName]['description'] = $pageTsConfigDescription;
67  }
68  }
69  return $result;
70  }
71 
78  protected function ‪translateDescriptions(array $result): array
79  {
80  $languageService = $this->‪getLanguageService();
81  foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfiguration) {
82  if (!isset($fieldConfiguration['description'])) {
83  continue;
84  }
85  $result['processedTca']['columns'][$fieldName]['description'] = $languageService->sL($fieldConfiguration['description']);
86  }
87  return $result;
88  }
89 
91  {
92  return ‪$GLOBALS['LANG'];
93  }
94 }
‪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
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessFieldDescriptions\getLanguageService
‪getLanguageService()
Definition: TcaColumnsProcessFieldDescriptions.php:90
‪$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:46
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessFieldDescriptions\translateDescriptions
‪array translateDescriptions(array $result)
Definition: TcaColumnsProcessFieldDescriptions.php:78