‪TYPO3CMS  10.4
FinisherOptionsFlexFormOverridesConverter.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 {
33  protected ‪$converterDto;
34 
39  {
40  $this->converterDto = ‪$converterDto;
41  }
42 
55  public function ‪__invoke(string $_, $__, array $matches): void
56  {
57  [, $optionKey] = $matches;
58  $prototypeFinisherDefinition = $this->converterDto->getPrototypeFinisherDefinition();
59  $finisherDefinition = $this->converterDto->getFinisherDefinition();
60  $finisherIdentifier = $this->converterDto->getFinisherIdentifier();
61  $flexFormSheetSettings = $this->converterDto->getFlexFormSheetSettings();
62 
63  try {
65  $flexFormSheetSettings['finishers'][$finisherIdentifier],
66  $optionKey,
67  '.'
68  );
69  } catch (‪MissingArrayPathException $exception) {
70  return;
71  }
72 
73  $fieldConfiguration = $prototypeFinisherDefinition['FormEngine']['elements'][$optionKey];
74 
75  if ($fieldConfiguration['section'] ?? false) {
76  $processedOptionValue = [];
77 
78  foreach ($value ?: [] as $optionListValue) {
79  $key = $optionListValue[$fieldConfiguration['sectionItemKey']];
80  $value = $optionListValue[$fieldConfiguration['sectionItemValue']];
81  $processedOptionValue[$key] = $value;
82  }
83 
84  if (empty($processedOptionValue)) {
85  $value = $optionValue;
86  } else {
87  $value = $processedOptionValue;
88  }
89  }
90 
91  $finisherDefinition = ‪ArrayUtility::setValueByPath($finisherDefinition, 'options.' . $optionKey, $value, '.');
92 
93  $this->converterDto->setFinisherDefinition($finisherDefinition);
94  }
95 }
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Converters\FinisherOptionsFlexFormOverridesConverter\__construct
‪__construct(FlexFormFinisherOverridesConverterDto $converterDto)
Definition: FinisherOptionsFlexFormOverridesConverter.php:37
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Converters
Definition: AbstractConverter.php:18
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Converters\FinisherOptionsFlexFormOverridesConverter
Definition: FinisherOptionsFlexFormOverridesConverter.php:29
‪TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException
Definition: MissingArrayPathException.php:28
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Converters\FinisherOptionsFlexFormOverridesConverter\$converterDto
‪FlexFormFinisherOverridesConverterDto $converterDto
Definition: FinisherOptionsFlexFormOverridesConverter.php:32
‪TYPO3\CMS\Core\Utility\ArrayUtility\getValueByPath
‪static mixed getValueByPath(array $array, $path, $delimiter='/')
Definition: ArrayUtility.php:180
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Converters\FinisherOptionsFlexFormOverridesConverter\__invoke
‪__invoke(string $_, $__, array $matches)
Definition: FinisherOptionsFlexFormOverridesConverter.php:54
‪TYPO3\CMS\Core\Utility\ArrayUtility\setValueByPath
‪static array setValueByPath(array $array, $path, $value, $delimiter='/')
Definition: ArrayUtility.php:272
‪TYPO3\CMS\Core\Utility\ArrayUtility
Definition: ArrayUtility.php:24
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Converters\FlexFormFinisherOverridesConverterDto
Definition: FlexFormFinisherOverridesConverterDto.php:24