‪TYPO3CMS  10.4
FieldInformation.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 
23 
33 {
41  public function ‪render(): array
42  {
43  $result = $this->‪initializeResultArray();
44  if (!isset($this->data['renderData']['fieldInformation'])) {
45  return $result;
46  }
47 
48  $fieldInformations = $this->data['renderData']['fieldInformation'];
49  $orderingService = GeneralUtility::makeInstance(DependencyOrderingService::class);
50  $orderedFieldInformation = $orderingService->orderByDependencies($fieldInformations, 'before', 'after');
51 
52  foreach ($orderedFieldInformation as $anOrderedFieldInformation => $orderedFieldInformationConfiguration) {
53  if (isset($orderedFieldInformationConfiguration['disabled']) && $orderedFieldInformationConfiguration['disabled']
54  || !isset($fieldInformations[$anOrderedFieldInformation]['renderType'])
55  ) {
56  // Don't consider this control if disabled.
57  // Also ignore if renderType is not given.
58  // Missing renderType may happen if an element registers a default field control
59  // as disabled, and TCA enabled that. If then additionally for instance the
60  // element renderType is changed to an element that doesn't register the control
61  // by default anymore, this would then fatal if we don't continue here.
62  // @todo: the above scenario indicates a small configuration flaw, maybe log an error somewhere?
63  continue;
64  }
65 
66  $options = ‪$this->data;
67  $options['renderType'] = $fieldInformations[$anOrderedFieldInformation]['renderType'];
68  $options['renderData']['fieldInformationOptions'] = $orderedFieldInformationConfiguration['options'] ?? [];
69  $informationResult = $this->nodeFactory->create($options)->render();
70 
71  $allowedTags = '<a><br><br/><div><em><i><p><strong><span><code>';
72  if (strip_tags($informationResult['html'], $allowedTags) !== $informationResult['html']) {
73  throw new \RuntimeException(
74  'The field information API supports only a limited number of HTML tags within the result'
75  . ' HTML of children. Allowed tags are: "' . $allowedTags . '" Child'
76  . ' ' . $options['renderType'] . ' violated this rule. Either remove offending tags or'
77  . ' switch to a different API like "fieldWizard" or "fieldControl".',
78  1485084419
79  );
80  }
81 
82  $result = $this->‪mergeChildReturnIntoExistingResult($result, $informationResult);
83  }
84  return $result;
85  }
86 }
‪TYPO3\CMS\Backend\Form\NodeExpansion\FieldInformation
Definition: FieldInformation.php:33
‪TYPO3\CMS\Backend\Form\AbstractNode\mergeChildReturnIntoExistingResult
‪array mergeChildReturnIntoExistingResult(array $existing, array $childReturn, bool $mergeHtml=true)
Definition: AbstractNode.php:116
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪array initializeResultArray()
Definition: AbstractNode.php:90
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:42
‪TYPO3\CMS\Core\Service\DependencyOrderingService
Definition: DependencyOrderingService.php:32
‪TYPO3\CMS\Backend\Form\NodeExpansion
Definition: FieldControl.php:18
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Form\NodeExpansion\FieldInformation\render
‪array render()
Definition: FieldInformation.php:41