‪TYPO3CMS  10.4
CollectionBasedValidator.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 
27 {
28 
41  array ‪$currentElement,
42  $value,
43  string ‪$sessionToken,
44  ‪ValidationDto $dto
45  ): void {
46  $hmacDataPath = $this->‪buildHmacDataPath($dto->‪getPropertyPath());
47  if (‪ArrayUtility::isValidPath(‪$currentElement, $hmacDataPath, '.')) {
48  $hmacData = ‪ArrayUtility::getValueByPath(‪$currentElement, $hmacDataPath, '.');
49 
50  $hmacContent = [
54  $dto->‪getPropertyPath()
55  ];
56 
57  if (!$this->‪getFormDefinitionValidationService()->isPropertyValueEqualToHistoricalValue($hmacContent, $value, $hmacData, ‪$sessionToken)) {
58  $message = 'The value "%s" of property "%s" (form element "%s" / "%s.%s") is not equal to the historical value "%s" #1528591586';
59  throw new ‪PropertyException(
60  sprintf(
61  $message,
62  $value,
63  $dto->‪getPropertyPath(),
67  $hmacData['value'] ?? ''
68  ),
69  1528591586
70  );
71  }
72  } else {
73  $message = 'No hmac found for property "%s" (form element "%s" / "%s.%s") #1528591585';
74  throw new ‪PropertyException(
75  sprintf(
76  $message,
77  $dto->‪getPropertyPath(),
81  ),
82  1528591585
83  );
84  }
85  }
86 }
‪TYPO3\CMS\Extbase\Property\Exception
Definition: DuplicateObjectException.php:18
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\AbstractValidator\$sessionToken
‪string $sessionToken
Definition: AbstractValidator.php:41
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\AbstractValidator\$currentElement
‪array $currentElement
Definition: AbstractValidator.php:37
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\ValidationDto
Definition: ValidationDto.php:23
‪TYPO3\CMS\Core\Utility\ArrayUtility\isValidPath
‪static bool isValidPath(array $array, $path, $delimiter='/')
Definition: ArrayUtility.php:144
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\AbstractValidator\buildHmacDataPath
‪string buildHmacDataPath(string $propertyPath)
Definition: AbstractValidator.php:65
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\ValidationDto\getPropertyPath
‪string getPropertyPath()
Definition: ValidationDto.php:100
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\ValidationDto\getFormElementIdentifier
‪string getFormElementIdentifier()
Definition: ValidationDto.php:92
‪TYPO3\CMS\Core\Utility\ArrayUtility\getValueByPath
‪static mixed getValueByPath(array $array, $path, $delimiter='/')
Definition: ArrayUtility.php:180
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\AbstractValidator\getFormDefinitionValidationService
‪FormDefinitionValidationService getFormDefinitionValidationService()
Definition: AbstractValidator.php:77
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\CollectionBasedValidator
Definition: CollectionBasedValidator.php:27
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\ValidationDto\getPropertyCollectionElementIdentifier
‪string getPropertyCollectionElementIdentifier()
Definition: ValidationDto.php:116
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\CollectionBasedValidator\validatePropertyCollectionElementPropertyValueByHmacData
‪validatePropertyCollectionElementPropertyValueByHmacData(array $currentElement, $value, string $sessionToken, ValidationDto $dto)
Definition: CollectionBasedValidator.php:40
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators
Definition: AbstractValidator.php:18
‪TYPO3\CMS\Core\Utility\ArrayUtility
Definition: ArrayUtility.php:24
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\AbstractValidator
Definition: AbstractValidator.php:29
‪TYPO3\CMS\Form\Domain\Configuration\Exception\PropertyException
Definition: PropertyException.php:26
‪TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\ValidationDto\getPropertyCollectionName
‪string getPropertyCollectionName()
Definition: ValidationDto.php:108