TYPO3 CMS  TYPO3_8-7
ProcessingRule.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Form\Mvc;
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 
24 
33 {
34 
40  protected $dataType;
41 
46 
50  protected $validator;
51 
56 
60  protected $propertyMapper;
61 
67  {
68  $this->propertyMappingConfiguration = $propertyMappingConfiguration;
69  }
70 
75  public function injectConjunctionValidator(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator $validator)
76  {
77  $this->validator = $validator;
78  }
79 
84  public function injectPropertyMapper(\TYPO3\CMS\Extbase\Property\PropertyMapper $propertyMapper)
85  {
86  $this->propertyMapper = $propertyMapper;
87  }
88 
93  public function __construct()
94  {
95  $this->processingMessages = GeneralUtility::makeInstance(ObjectManager::class)
96  ->get(Result::class);
97  }
98 
104  {
106  }
107 
112  public function getDataType(): string
113  {
114  return $this->dataType;
115  }
116 
121  public function setDataType(string $dataType)
122  {
123  $this->dataType = $dataType;
124  }
125 
132  public function getValidators(): \SplObjectStorage
133  {
134  return $this->validator->getValidators();
135  }
136 
142  {
143  $this->validator->addValidator($validator);
144  }
145 
151  public function process($value)
152  {
153  if ($this->dataType !== null) {
154  $value = $this->propertyMapper->convert($value, $this->dataType, $this->propertyMappingConfiguration);
155  $messages = $this->propertyMapper->getMessages();
156  } else {
157  $messages = GeneralUtility::makeInstance(ObjectManager::class)
158  ->get(Result::class);
159  }
160 
161  $validationResult = $this->validator->validate($value);
162  $messages->merge($validationResult);
163 
164  $this->processingMessages->merge($messages);
165  return $value;
166  }
167 
172  public function getProcessingMessages(): Result
173  {
175  }
176 }
injectConjunctionValidator(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator $validator)
static makeInstance($className,... $constructorArguments)
injectPropertyMapper(\TYPO3\CMS\Extbase\Property\PropertyMapper $propertyMapper)
addValidator(ValidatorInterface $validator)
injectPropertyMappingConfiguration(\TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration $propertyMappingConfiguration)