[BUGFIX] Fix several typos in php comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Domain / Configuration / FormDefinition / Validators / CreatableFormElementPropertiesValidator.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators;
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
18 use TYPO3\CMS\Form\Domain\Configuration\Exception\PropertyException;
19
20 /**
21 * @internal
22 */
23 class CreatableFormElementPropertiesValidator extends ElementBasedValidator
24 {
25
26 /**
27 * Checks if the form element property is defined within the form editor setup
28 * or if the property is defined within the "predefinedDefaults" in the form editor setup
29 * and the property value matches the predefined value
30 * or if there is a valid hmac hash for the value.
31 *
32 * @param string $key
33 * @param mixed $value
34 */
35 public function __invoke(string $key, $value)
36 {
37 $dto = $this->validationDto->withPropertyPath($key);
38
39 if (!$this->getConfigurationService()->isFormElementPropertyDefinedInFormEditorSetup($dto)) {
40 if ($this->getConfigurationService()->isFormElementPropertyDefinedInPredefinedDefaultsInFormEditorSetup($dto)) {
41 $predefinedDefaultValue = $this->getConfigurationService()->getFormElementPredefinedDefaultValueFromFormEditorSetup($dto);
42 if ($value !== $predefinedDefaultValue) {
43 $message = 'The value "%s" of property "%s" (form element "%s") is not equal to the default value "%s" #1528588035';
44 throw new PropertyException(
45 sprintf(
46 $message,
47 $value,
48 $dto->getPropertyPath(),
49 $dto->getFormElementIdentifier(),
50 $predefinedDefaultValue
51 ),
52 1528588035
53 );
54 }
55 } else {
56 $this->validateFormElementPropertyValueByHmacData(
57 $this->currentElement,
58 $value,
59 $this->sessionToken,
60 $dto
61 );
62 }
63 }
64 }
65 }