‪TYPO3CMS  11.5
TYPO3\CMS\Extbase\Validation\ValidatorResolver Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Validation\ValidatorResolver:

Public Member Functions

 injectReflectionService (ReflectionService $reflectionService)
TYPO3 CMS Extbase Validation Validator ValidatorInterface createValidator ($validatorType, array $validatorOptions=[])
ConjunctionValidator getBaseValidatorConjunction ($targetClassName)

Protected Member Functions

 buildBaseValidatorConjunction ($indexKey, $targetClassName, array $validationGroups=[])

Protected Attributes

TYPO3 CMS Extbase Reflection ReflectionService $reflectionService
array $baseValidatorConjunctions = array( )

Detailed Description

Validator resolver to automatically find an appropriate validator for a given subject

only to be used within Extbase, not part of TYPO3 Core API.

Definition at line 33 of file ValidatorResolver.php.

Member Function Documentation

◆ buildBaseValidatorConjunction()

TYPO3\CMS\Extbase\Validation\ValidatorResolver::buildBaseValidatorConjunction (   $indexKey,
array  $validationGroups = [] 

Builds a base validator conjunction for the given data type.

The base validation rules are those which were declared directly in a class (typically a model) through some validate annotations on properties.

If a property holds a class for which a base validator exists, that property will be checked as well, regardless of a validate annotation

Additionally, if a custom validator was defined for the class in question, it will be added to the end of the conjunction. A custom validator is found if it follows the naming convention "Replace '\Model\' by '\Validator\' and append 'Validator'".

Example: $targetClassName is TYPO3\Foo\Domain\Model\Quux, then the validator will be found if it has the name TYPO3\Foo\Domain\Validator\QuuxValidator

string$indexKey‪The key to use as index in $this->baseValidatorConjunctions; calculated from target class name and validation groups
string$targetClassName‪The data type to build the validation conjunction for. Needs to be the fully qualified class name.
array$validationGroups‪The validation groups to build the validator for

Definition at line 132 of file ValidatorResolver.php.

References TYPO3\CMS\Extbase\Validation\ValidatorResolver\createValidator(), TYPO3\CMS\Extbase\Validation\ValidatorResolver\getBaseValidatorConjunction(), TYPO3\CMS\Extbase\Utility\TypeHandlingUtility\isCollectionType(), TYPO3\CMS\Extbase\Utility\TypeHandlingUtility\isCoreType(), and TYPO3\CMS\Extbase\Utility\TypeHandlingUtility\isSimpleType().

Referenced by TYPO3\CMS\Extbase\Validation\ValidatorResolver\getBaseValidatorConjunction().

◆ createValidator()

TYPO3 CMS Extbase Validation Validator ValidatorInterface TYPO3\CMS\Extbase\Validation\ValidatorResolver::createValidator (   $validatorType,
array  $validatorOptions = [] 

Get a validator for a given data type. Returns a validator implementing the \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface or NULL if no validator could be resolved.

string$validatorType‪Either one of the built-in data types or fully qualified validator class name
array$validatorOptions‪Options to be passed to the validator
‪\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface Validator or NULL if none found.
‪remove throwing Exceptions in resolveValidatorObjectName

Definition at line 60 of file ValidatorResolver.php.

References $validator, and TYPO3\CMS\Extbase\Validation\ValidatorClassNameResolver\resolve().

Referenced by TYPO3\CMS\Extbase\Validation\ValidatorResolver\buildBaseValidatorConjunction().

◆ getBaseValidatorConjunction()

ConjunctionValidator TYPO3\CMS\Extbase\Validation\ValidatorResolver::getBaseValidatorConjunction (   $targetClassName)

Resolves and returns the base validator conjunction for the given data type.

If no validator could be resolved (which usually means that no validation is necessary), NULL is returned.

string$targetClassName‪The data type to search a validator for. Usually the fully qualified object name
‪ConjunctionValidator The validator conjunction or NULL

Definition at line 101 of file ValidatorResolver.php.

References TYPO3\CMS\Extbase\Validation\ValidatorResolver\buildBaseValidatorConjunction().

Referenced by TYPO3\CMS\Extbase\Validation\ValidatorResolver\buildBaseValidatorConjunction().

◆ injectReflectionService()

TYPO3\CMS\Extbase\Validation\ValidatorResolver::injectReflectionService ( ReflectionService  $reflectionService)

Definition at line 46 of file ValidatorResolver.php.

References TYPO3\CMS\Extbase\Validation\ValidatorResolver\$reflectionService.

Member Data Documentation

◆ $baseValidatorConjunctions

array TYPO3\CMS\Extbase\Validation\ValidatorResolver::$baseValidatorConjunctions = array( )

Definition at line 41 of file ValidatorResolver.php.

◆ $reflectionService

TYPO3 CMS Extbase Reflection ReflectionService TYPO3\CMS\Extbase\Validation\ValidatorResolver::$reflectionService