Passed
Push — master ( a7eef0...bd92b3 )
by
unknown
28:58 queued 15:52
created

AbstractValidator::getObjectManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
18
namespace TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators;
19
20
use TYPO3\CMS\Core\Utility\GeneralUtility;
21
use TYPO3\CMS\Form\Domain\Configuration\ConfigurationService;
22
use TYPO3\CMS\Form\Domain\Configuration\FormDefinitionValidationService;
23
24
/**
25
 * @internal
26
 */
27
abstract class AbstractValidator implements ValidatorInterface
28
{
29
    /**
30
     * @var array
31
     */
32
    protected $currentElement;
33
34
    /**
35
     * @var string
36
     */
37
    protected $sessionToken;
38
39
    /**
40
     * @var ValidationDto
41
     */
42
    protected $validationDto;
43
44
    /**
45
     * @param array $currentElement
46
     * @param string $sessionToken
47
     * @param ValidationDto $validationDto
48
     */
49
    public function __construct(array $currentElement, string $sessionToken, ValidationDto $validationDto)
50
    {
51
        $this->currentElement = $currentElement;
52
        $this->sessionToken = $sessionToken;
53
        $this->validationDto = $validationDto;
54
    }
55
56
    /**
57
     * Builds the path in which the hmac value is expected based on the property path.
58
     *
59
     * @param string $propertyPath
60
     * @return string
61
     */
62
    protected function buildHmacDataPath(string $propertyPath): string
63
    {
64
        $pathParts = explode('.', $propertyPath);
65
        $lastPathSegment = array_pop($pathParts);
66
        $pathParts[] = '_orig_' . $lastPathSegment;
67
68
        return implode('.', $pathParts);
69
    }
70
71
    /**
72
     * @return FormDefinitionValidationService
73
     */
74
    protected function getFormDefinitionValidationService(): FormDefinitionValidationService
75
    {
76
        return GeneralUtility::makeInstance(FormDefinitionValidationService::class);
77
    }
78
79
    /**
80
     * @return ConfigurationService
81
     */
82
    protected function getConfigurationService(): ConfigurationService
83
    {
84
        return GeneralUtility::makeInstance(ConfigurationService::class);
85
    }
86
}
87