‪TYPO3CMS  ‪main
FieldWizard.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 
37 {
38  public function ‪__construct(
39  private readonly ‪NodeFactory $nodeFactory,
40  private readonly ‪DependencyOrderingService $dependencyOrderingService,
41  ) {}
42 
50  public function ‪render(): array
51  {
52  $result = $this->‪initializeResultArray();
53  if (!isset($this->data['renderData']['fieldWizard'])) {
54  return $result;
55  }
56 
57  $fieldWizard = $this->data['renderData']['fieldWizard'];
58  $orderedFieldWizard = $this->dependencyOrderingService->orderByDependencies($fieldWizard);
59 
60  foreach ($orderedFieldWizard as $anOrderedFieldWizard => $orderedFieldWizardConfiguration) {
61  if (isset($orderedFieldWizardConfiguration['disabled']) && $orderedFieldWizardConfiguration['disabled']
62  || !isset($fieldWizard[$anOrderedFieldWizard]['renderType'])
63  ) {
64  // Don't consider this control if disabled.
65  // Also ignore if renderType is not given.
66  // Missing renderType may happen if an element registers a default field control
67  // as disabled, and TCA enabled that. If then additionally for instance the
68  // element renderType is changed to an element that doesn't register the control
69  // by default anymore, this would then fatal if we don't continue here.
70  // @todo: the above scenario indicates a small configuration flaw, maybe log an error somewhere?
71  continue;
72  }
73 
74  $options = ‪$this->data;
75  $options['renderType'] = $fieldWizard[$anOrderedFieldWizard]['renderType'];
76  $options['renderData']['fieldWizardOptions'] = $orderedFieldWizardConfiguration['options'] ?? [];
77  $wizardResult = $this->nodeFactory->create($options)->render();
78  $result = $this->‪mergeChildReturnIntoExistingResult($result, $wizardResult);
79  }
80  return $result;
81  }
82 }
‪TYPO3\CMS\Backend\Form\AbstractNode\mergeChildReturnIntoExistingResult
‪array mergeChildReturnIntoExistingResult(array $existing, array $childReturn, bool $mergeHtml=true)
Definition: AbstractNode.php:104
‪TYPO3\CMS\Backend\Form\NodeExpansion\FieldWizard\__construct
‪__construct(private readonly NodeFactory $nodeFactory, private readonly DependencyOrderingService $dependencyOrderingService,)
Definition: FieldWizard.php:38
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:35
‪TYPO3\CMS\Core\Service\DependencyOrderingService
Definition: DependencyOrderingService.php:32
‪TYPO3\CMS\Backend\Form\NodeExpansion\FieldWizard\render
‪array render()
Definition: FieldWizard.php:50
‪TYPO3\CMS\Backend\Form\NodeExpansion
Definition: FieldControl.php:18
‪TYPO3\CMS\Backend\Form\NodeFactory
Definition: NodeFactory.php:40
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29
‪TYPO3\CMS\Backend\Form\NodeExpansion\FieldWizard
Definition: FieldWizard.php:37
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪initializeResultArray()
Definition: AbstractNode.php:77