3c57f4438c285724dc12f1803307d6e8b867d0ac
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / FieldInformation / TcaDescription.php
1 <?php
2 declare(strict_types = 1);
3
4 namespace TYPO3\CMS\Backend\Form\FieldInformation;
5
6 /*
7 * This file is part of the TYPO3 CMS project.
8 *
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
12 *
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
15 *
16 * The TYPO3 project - inspiring people to share!
17 */
18
19 use TYPO3\CMS\Backend\Form\AbstractNode;
20 use TYPO3\CMS\Core\Localization\LanguageService;
21
22 /**
23 * Render localized ['columns']['theField']['description'] text as default
24 * field information node. This is typically displayed in elements below the
25 * element label and the field content.
26 */
27 class TcaDescription extends AbstractNode
28 {
29 /**
30 * Handler for single nodes
31 *
32 * @return array As defined in initializeResultArray() of AbstractNode
33 */
34 public function render(): array
35 {
36 $resultArray = $this->initializeResultArray();
37 if (!empty($this->data['parameterArray']['fieldConf']['description'])) {
38 $fieldInformationText = $this->getLanguageService()->sL($this->data['parameterArray']['fieldConf']['description']);
39 if (trim($fieldInformationText) !== '') {
40 $resultArray['html'] = htmlspecialchars($fieldInformationText);
41 }
42 }
43 return $resultArray;
44 }
45
46 /**
47 * Returns the LanguageService
48 *
49 * @return LanguageService
50 */
51 protected function getLanguageService(): LanguageService
52 {
53 return $GLOBALS['LANG'];
54 }
55 }