TYPO3 CMS  TYPO3_8-7
CollectionBasedValidator.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 
20 
25 {
26 
39  array $currentElement,
40  $value,
41  string $sessionToken,
42  ValidationDto $dto
43  ) {
44  $hmacDataPath = $this->buildHmacDataPath($dto->getPropertyPath());
45  if (ArrayUtility::isValidPath($currentElement, $hmacDataPath, '.')) {
46  $hmacData = ArrayUtility::getValueByPath($currentElement, $hmacDataPath, '.');
47 
48  $hmacContent = [
52  $dto->getPropertyPath()
53  ];
54 
55  if (!$this->getFormDefinitionValidationService()->isPropertyValueEqualToHistoricalValue($hmacContent, $value, $hmacData, $sessionToken)) {
56  $message = 'The value "%s" of property "%s" (form element "%s" / "%s.%s") is not equal to the historical value "%s" #1528591586';
57  throw new PropertyException(
58  sprintf(
59  $message,
60  $value,
61  $dto->getPropertyPath(),
65  $hmacData['value'] ?? ''
66  ),
67  1528591586
68  );
69  }
70  } else {
71  $message = 'No hmac found for property "%s" (form element "%s" / "%s.%s") #1528591585';
72  throw new PropertyException(
73  sprintf(
74  $message,
75  $dto->getPropertyPath(),
79  ),
80  1528591585
81  );
82  }
83  }
84 }
static getValueByPath(array $array, $path, $delimiter='/')
validatePropertyCollectionElementPropertyValueByHmacData(array $currentElement, $value, string $sessionToken, ValidationDto $dto)
static isValidPath(array $array, $path, $delimiter='/')