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