TYPO3 CMS  TYPO3_8-7
AddHmacDataConverter.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 
22 
27 {
28 
39  public function __invoke(string $key, $value)
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(
63  ArrayProcessing::class,
64  'addHmacData',
65  '^(?!(.*\._label|.*\._value)$).*',
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(
82  ArrayProcessing::class,
83  'addHmacData',
84  '^(?!(.*\._label|.*\._value)$).*',
86  AddHmacDataToPropertyCollectionElementConverter::class,
87  $this->converterDto,
88  $this->sessionToken
89  )
90  )
91  );
92  }
93  }
94 }
static getValueByPath(array $array, $path, $delimiter='/')
static makeInstance($className,... $constructorArguments)