ValidatorResolver implements SingletonInterface

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

Internal

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

Table of Contents

Interfaces

SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$baseValidatorConjunctions  : array
$reflectionService  : ReflectionService

Methods

createValidator()  : ValidatorInterface
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.
getBaseValidatorConjunction()  : ConjunctionValidator
Resolves and returns the base validator conjunction for the given data type.
injectReflectionService()  : mixed
buildBaseValidatorConjunction()  : mixed
Builds a base validator conjunction for the given data type.

Properties

$baseValidatorConjunctions

protected array $baseValidatorConjunctions = []

Methods

createValidator()

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.

public createValidator(string $validatorType[, array $validatorOptions = [] ]) : ValidatorInterface
Parameters
$validatorType : string

Either one of the built-in data types or fully qualified validator class name

$validatorOptions : array = []

Options to be passed to the validator

Return values
ValidatorInterface —

Validator or NULL if none found.

getBaseValidatorConjunction()

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

public getBaseValidatorConjunction(string $targetClassName) : ConjunctionValidator

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

Parameters
$targetClassName : string

The data type to search a validator for. Usually the fully qualified object name

Return values
ConjunctionValidator —

The validator conjunction or NULL

buildBaseValidatorConjunction()

Builds a base validator conjunction for the given data type.

protected buildBaseValidatorConjunction(string $indexKey, string $targetClassName[, array $validationGroups = [] ]) : mixed

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

Parameters
$indexKey : string

The key to use as index in $this->baseValidatorConjunctions; calculated from target class name and validation groups

$targetClassName : string

The data type to build the validation conjunction for. Needs to be the fully qualified class name.

$validationGroups : array = []

The validation groups to build the validator for

Tags
throws
NoSuchValidatorException
throws
InvalidArgumentException
On this page

Search results