‪TYPO3CMS  9.5
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 
23 
32 {
33 
39  protected ‪$dataType;
40 
45 
49  protected ‪$validator;
50 
55 
59  protected ‪$propertyMapper;
60 
66  {
67  $this->propertyMappingConfiguration = ‪$propertyMappingConfiguration;
68  }
69 
74  public function ‪injectConjunctionValidator(\‪TYPO3\CMS\‪Extbase\Validation\Validator\ConjunctionValidator ‪$validator)
75  {
76  $this->validator = ‪$validator;
77  }
78 
83  public function ‪injectPropertyMapper(\‪TYPO3\CMS\‪Extbase\Property\PropertyMapper ‪$propertyMapper)
84  {
85  $this->propertyMapper = ‪$propertyMapper;
86  }
87 
92  public function ‪__construct()
93  {
94  $this->processingMessages = GeneralUtility::makeInstance(ObjectManager::class)
95  ->get(Result::class);
96  }
97 
103  {
105  }
106 
111  public function ‪getDataType(): string
112  {
113  return ‪$this->dataType;
114  }
115 
120  public function ‪setDataType(string ‪$dataType)
121  {
122  $this->dataType = ‪$dataType;
123  }
124 
131  public function ‪getValidators(): \SplObjectStorage
132  {
133  return $this->validator->getValidators();
134  }
135 
141  {
142  $this->validator->addValidator(‪$validator);
143  }
144 
153  {
154  $this->validator->removeValidator(‪$validator);
155  }
156 
162  public function ‪process($value)
163  {
164  if ($this->dataType !== null) {
165  $value = $this->propertyMapper->convert($value, $this->dataType, $this->propertyMappingConfiguration);
166  $messages = $this->propertyMapper->getMessages();
167  } else {
168  $messages = GeneralUtility::makeInstance(ObjectManager::class)
169  ->get(Result::class);
170  }
171 
172  $validationResult = $this->validator->validate($value);
173  $messages->merge($validationResult);
174 
175  $this->processingMessages->merge($messages);
176  return $value;
177  }
178 
183  public function ‪getProcessingMessages(): ‪Result
184  {
186  }
187 }
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Form\Mvc\ProcessingRule\getDataType
‪string getDataType()
Definition: ProcessingRule.php:106
‪TYPO3\CMS\Form\Mvc\ProcessingRule\addValidator
‪addValidator(ValidatorInterface $validator)
Definition: ProcessingRule.php:135
‪TYPO3\CMS\Form\Mvc\ProcessingRule\getPropertyMappingConfiguration
‪PropertyMappingConfiguration getPropertyMappingConfiguration()
Definition: ProcessingRule.php:97
‪TYPO3\CMS\Form\Mvc\ProcessingRule\$dataType
‪string $dataType
Definition: ProcessingRule.php:38
‪TYPO3\CMS\Form\Mvc\ProcessingRule\injectConjunctionValidator
‪injectConjunctionValidator(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator $validator)
Definition: ProcessingRule.php:69
‪TYPO3\CMS\Form\Mvc\ProcessingRule\__construct
‪__construct()
Definition: ProcessingRule.php:87
‪TYPO3\CMS\Form\Mvc\ProcessingRule\$propertyMappingConfiguration
‪TYPO3 CMS Extbase Property PropertyMappingConfiguration $propertyMappingConfiguration
Definition: ProcessingRule.php:42
‪TYPO3\CMS\Form\Mvc\ProcessingRule\$propertyMapper
‪TYPO3 CMS Extbase Property PropertyMapper $propertyMapper
Definition: ProcessingRule.php:54
‪TYPO3
‪TYPO3\CMS\Form\Mvc\ProcessingRule\removeValidator
‪removeValidator(ValidatorInterface $validator)
Definition: ProcessingRule.php:147
‪TYPO3\CMS\Extbase\Error\Result
Definition: Result.php:20
‪TYPO3\CMS\Form\Mvc\ProcessingRule\injectPropertyMappingConfiguration
‪injectPropertyMappingConfiguration(\TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration $propertyMappingConfiguration)
Definition: ProcessingRule.php:60
‪TYPO3\CMS\Form\Mvc\ProcessingRule\getValidators
‪SplObjectStorage< ValidatorInterface > getValidators()
Definition: ProcessingRule.php:126
‪TYPO3\CMS\Form\Mvc\ProcessingRule\injectPropertyMapper
‪injectPropertyMapper(\TYPO3\CMS\Extbase\Property\PropertyMapper $propertyMapper)
Definition: ProcessingRule.php:78
‪TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration
Definition: PropertyMappingConfiguration.php:21
‪TYPO3\CMS\Form\Mvc\ProcessingRule\setDataType
‪setDataType(string $dataType)
Definition: ProcessingRule.php:115
‪TYPO3\CMS\Form\Mvc\ProcessingRule\process
‪mixed process($value)
Definition: ProcessingRule.php:157
‪TYPO3\CMS\Form\Mvc\ProcessingRule\$processingMessages
‪TYPO3 CMS Extbase Error Result $processingMessages
Definition: ProcessingRule.php:50
‪TYPO3\CMS\Form\Mvc\ProcessingRule\getProcessingMessages
‪Result getProcessingMessages()
Definition: ProcessingRule.php:178
‪TYPO3\CMS\Form\Mvc\ProcessingRule\$validator
‪TYPO3 CMS Extbase Validation Validator ConjunctionValidator $validator
Definition: ProcessingRule.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface
Definition: ValidatorInterface.php:21
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:25
‪TYPO3\CMS\Form\Mvc\ProcessingRule
Definition: ProcessingRule.php:32
‪TYPO3\CMS\Form\Mvc