‪TYPO3CMS  10.4
AddHmacDataConverter.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 
24 
29 {
30 
41  public function ‪__invoke(string $key, $value): void
42  {
43  $formDefinition = $this->converterDto->getFormDefinition();
44 
45  $renderablePathParts = explode('.', $key);
46  array_pop($renderablePathParts);
47 
48  if (count($renderablePathParts) > 1) {
49  $renderablePath = implode('.', $renderablePathParts);
50  $currentFormElement = ‪ArrayUtility::getValueByPath($formDefinition, $renderablePath, '.');
51  } else {
52  $currentFormElement = $formDefinition;
53  }
54 
55  $propertyCollectionElements = $currentFormElement['finishers'] ?? $currentFormElement['validators'] ?? [];
56  $propertyCollectionName = $currentFormElement['type'] === 'Form' ? 'finishers' : 'validators';
57  unset($currentFormElement['renderables'], $currentFormElement['finishers'], $currentFormElement['validators']);
58 
59  $this->converterDto
60  ->setRenderablePathParts($renderablePathParts)
61  ->setFormElementIdentifier($value);
62 
63  GeneralUtility::makeInstance(ArrayProcessor::class, $currentFormElement)->forEach(
64  GeneralUtility::makeInstance(
65  ArrayProcessing::class,
66  'addHmacData',
67  '^.*',
68  GeneralUtility::makeInstance(
69  AddHmacDataToFormElementPropertyConverter::class,
70  $this->converterDto,
71  $this->sessionToken
72  )
73  )
74  );
75 
76  $this->converterDto->setPropertyCollectionName($propertyCollectionName);
77  foreach ($propertyCollectionElements as $propertyCollectionIndex => $propertyCollectionElement) {
78  $this->converterDto
79  ->setPropertyCollectionIndex((int)$propertyCollectionIndex)
80  ->setPropertyCollectionElementIdentifier($propertyCollectionElement['identifier']);
81 
82  GeneralUtility::makeInstance(ArrayProcessor::class, $propertyCollectionElement)->forEach(
83  GeneralUtility::makeInstance(
84  ArrayProcessing::class,
85  'addHmacData',
86  '^(?!(.*\._label|.*\._value)$).*',
87  GeneralUtility::makeInstance(
88  AddHmacDataToPropertyCollectionElementConverter::class,
89  $this->converterDto,
90  $this->sessionToken
91  )
92  )
93  );
94  }
95  }
96 }
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Converters\AddHmacDataConverter\__invoke
‪__invoke(string $key, $value)
Definition: AddHmacDataConverter.php:41
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Converters
Definition: AbstractConverter.php:18
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Converters\AddHmacDataConverter
Definition: AddHmacDataConverter.php:29
‪TYPO3\CMS\Form\Domain\Configuration\ArrayProcessing\ArrayProcessing
Definition: ArrayProcessing.php:27
‪TYPO3\CMS\Core\Utility\ArrayUtility\getValueByPath
‪static mixed getValueByPath(array $array, $path, $delimiter='/')
Definition: ArrayUtility.php:180
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Converters\AbstractConverter
Definition: AbstractConverter.php:24
‪TYPO3\CMS\Form\Domain\Configuration\ArrayProcessing\ArrayProcessor
Definition: ArrayProcessor.php:30
‪TYPO3\CMS\Core\Utility\ArrayUtility
Definition: ArrayUtility.php:24
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46