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