‪TYPO3CMS  10.4
ProcessingRule.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 
18 namespace ‪TYPO3\CMS\Form\Mvc;
19 
27 
36 {
37 
43  protected ‪$dataType;
44 
49 
53  protected ‪$validator;
54 
59 
63  protected ‪$propertyMapper;
64 
70  {
71  $this->propertyMappingConfiguration = ‪$propertyMappingConfiguration;
72  }
73 
79  {
80  $this->validator = ‪$validator;
81  }
82 
88  {
89  $this->propertyMapper = ‪$propertyMapper;
90  }
91 
96  public function ‪__construct()
97  {
98  $this->processingMessages = GeneralUtility::makeInstance(ObjectManager::class)
99  ->get(Result::class);
100  }
101 
107  {
109  }
110 
115  public function ‪getDataType(): string
116  {
117  return ‪$this->dataType;
118  }
119 
124  public function ‪setDataType(string ‪$dataType)
125  {
126  $this->dataType = ‪$dataType;
127  }
128 
135  public function ‪getValidators(): \SplObjectStorage
136  {
137  return $this->validator->getValidators();
138  }
139 
145  {
146  $this->validator->addValidator(‪$validator);
147  }
148 
157  {
158  $this->validator->removeValidator(‪$validator);
159  }
160 
166  public function ‪process($value)
167  {
168  if ($this->dataType !== null) {
169  $value = $this->propertyMapper->convert($value, $this->dataType, $this->propertyMappingConfiguration);
170  $messages = $this->propertyMapper->getMessages();
171  } else {
172  $messages = GeneralUtility::makeInstance(ObjectManager::class)
173  ->get(Result::class);
174  }
175 
176  $validationResult = $this->validator->validate($value);
177  $messages->merge($validationResult);
178 
179  $this->processingMessages->merge($messages);
180  return $value;
181  }
182 
187  public function ‪getProcessingMessages(): ‪Result
188  {
190  }
191 }
‪TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator
Definition: ConjunctionValidator.php:24
‪TYPO3\CMS\Form\Mvc\ProcessingRule\injectPropertyMapper
‪injectPropertyMapper(PropertyMapper $propertyMapper)
Definition: ProcessingRule.php:82
‪TYPO3\CMS\Form\Mvc\ProcessingRule\getDataType
‪string getDataType()
Definition: ProcessingRule.php:110
‪TYPO3\CMS\Form\Mvc\ProcessingRule\addValidator
‪addValidator(ValidatorInterface $validator)
Definition: ProcessingRule.php:139
‪TYPO3\CMS\Form\Mvc\ProcessingRule\getPropertyMappingConfiguration
‪PropertyMappingConfiguration getPropertyMappingConfiguration()
Definition: ProcessingRule.php:101
‪TYPO3\CMS\Form\Mvc\ProcessingRule\$dataType
‪string $dataType
Definition: ProcessingRule.php:42
‪TYPO3\CMS\Form\Mvc\ProcessingRule\__construct
‪__construct()
Definition: ProcessingRule.php:91
‪TYPO3\CMS\Form\Mvc\ProcessingRule\$propertyMappingConfiguration
‪TYPO3 CMS Extbase Property PropertyMappingConfiguration $propertyMappingConfiguration
Definition: ProcessingRule.php:46
‪TYPO3\CMS\Form\Mvc\ProcessingRule\$propertyMapper
‪TYPO3 CMS Extbase Property PropertyMapper $propertyMapper
Definition: ProcessingRule.php:58
‪TYPO3\CMS\Form\Mvc\ProcessingRule\removeValidator
‪removeValidator(ValidatorInterface $validator)
Definition: ProcessingRule.php:151
‪TYPO3\CMS\Extbase\Error\Result
Definition: Result.php:24
‪TYPO3\CMS\Form\Mvc\ProcessingRule\injectPropertyMappingConfiguration
‪injectPropertyMappingConfiguration(PropertyMappingConfiguration $propertyMappingConfiguration)
Definition: ProcessingRule.php:64
‪TYPO3\CMS\Form\Mvc\ProcessingRule\getValidators
‪SplObjectStorage getValidators()
Definition: ProcessingRule.php:130
‪TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration
Definition: PropertyMappingConfiguration.php:22
‪TYPO3\CMS\Form\Mvc\ProcessingRule\setDataType
‪setDataType(string $dataType)
Definition: ProcessingRule.php:119
‪TYPO3\CMS\Form\Mvc\ProcessingRule\process
‪mixed process($value)
Definition: ProcessingRule.php:161
‪TYPO3\CMS\Form\Mvc\ProcessingRule\$processingMessages
‪TYPO3 CMS Extbase Error Result $processingMessages
Definition: ProcessingRule.php:54
‪TYPO3\CMS\Extbase\Property\PropertyMapper
Definition: PropertyMapper.php:37
‪TYPO3\CMS\Form\Mvc\ProcessingRule\getProcessingMessages
‪Result getProcessingMessages()
Definition: ProcessingRule.php:182
‪TYPO3\CMS\Form\Mvc\ProcessingRule\$validator
‪TYPO3 CMS Extbase Validation Validator ConjunctionValidator $validator
Definition: ProcessingRule.php:50
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface
Definition: ValidatorInterface.php:22
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:28
‪TYPO3\CMS\Form\Mvc\ProcessingRule
Definition: ProcessingRule.php:36
‪TYPO3\CMS\Form\Mvc\ProcessingRule\injectConjunctionValidator
‪injectConjunctionValidator(ConjunctionValidator $validator)
Definition: ProcessingRule.php:73
‪TYPO3\CMS\Form\Mvc