TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
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 
25 
34 {
35 
41  protected $dataType;
42 
47 
51  protected $validator;
52 
57 
61  protected $propertyMapper;
62 
69  {
70  $this->propertyMappingConfiguration = $propertyMappingConfiguration;
71  }
72 
78  public function injectConjunctionValidator(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator $validator)
79  {
80  $this->validator = $validator;
81  }
82 
88  public function injectPropertyMapper(\TYPO3\CMS\Extbase\Property\PropertyMapper $propertyMapper)
89  {
90  $this->propertyMapper = $propertyMapper;
91  }
92 
97  public function __construct()
98  {
99  $this->processingMessages = GeneralUtility::makeInstance(ObjectManager::class)
100  ->get(Result::class);
101  }
102 
108  {
110  }
111 
116  public function getDataType(): string
117  {
118  return $this->dataType;
119  }
120 
125  public function setDataType(string $dataType)
126  {
127  $this->dataType = $dataType;
128  }
129 
136  public function getValidators(): \SplObjectStorage
137  {
138  return $this->validator->getValidators();
139  }
140 
147  {
148  $this->validator->addValidator($validator);
149  }
150 
156  public function process($value)
157  {
158  if ($this->dataType !== null) {
159  $value = $this->propertyMapper->convert($value, $this->dataType, $this->propertyMappingConfiguration);
160  $messages = $this->propertyMapper->getMessages();
161  } else {
162  $messages = GeneralUtility::makeInstance(ObjectManager::class)
163  ->get(Result::class);
164  }
165 
166  $validationResult = $this->validator->validate($value);
167  $messages->merge($validationResult);
168 
169  $this->processingMessages->merge($messages);
170  return $value;
171  }
172 
177  public function getProcessingMessages(): Result
178  {
180  }
181 }
injectPropertyMapper(\TYPO3\CMS\Extbase\Property\PropertyMapper $propertyMapper)
addValidator(ValidatorInterface $validator)
injectConjunctionValidator(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator $validator)
static makeInstance($className,...$constructorArguments)
injectPropertyMappingConfiguration(\TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration $propertyMappingConfiguration)