PHP Класс Neos\Flow\Validation\ValidatorResolver

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$baseValidatorConjunctions array
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
$reflectionService Neos\Flow\Reflection\ReflectionService

Открытые методы

Метод Описание
buildMethodArgumentsValidatorConjunctions ( string $className, string $methodName, array $methodParameters = null, array $methodValidateAnnotations = null ) : array Detects and registers any validators for arguments: - by the data type specified in the param annotations - additional validators specified in the validate annotations of a method
createValidator ( string $validatorType, array $validatorOptions = [] ) : Neos\Flow\Validation\Validator\ValidatorInterface Get a validator for a given data type. Returns a validator implementing the ValidatorInterface or NULL if no validator could be resolved.
getBaseValidatorConjunction ( string $targetClassName, array $validationGroups = ['Default'] ) : ConjunctionValidator Resolves and returns the base validator conjunction for the given data type.
getPolyTypeObjectValidatorImplementationClassNames ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array Returns a map of object validator class names.
getValidatorImplementationClassNames ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array Returns all class names implementing the ValidatorInterface.
reset ( ) : void Resets the baseValidatorConjunctions It is usually not required to reset the ValidatorResolver during one request. This method is mainly useful for functional tests

Защищенные методы

Метод Описание
addCustomValidators ( string $targetClassName, ConjunctionValidator &$conjunctionValidator ) : null | Neos\Flow\Validation\Validator\ObjectValidatorInterface This adds custom validators to the passed $conjunctionValidator.
buildBaseValidatorConjunction ( string $indexKey, string $targetClassName, array $validationGroups ) : void Builds a base validator conjunction for the given data type.
buildSubObjectValidator ( array $objectPath, Neos\Flow\Validation\Validator\ValidatorInterface $propertyValidator ) : GenericObjectValidator Builds a chain of nested object validators by specification of the given object path.
getValidatorType ( string $type ) : string Used to map PHP types to validator types.
resolveValidatorObjectName ( string $validatorType ) : string | boolean Returns the class name of an appropriate validator for the given type. If no validator is available FALSE is returned

Описание методов

addCustomValidators() защищенный Метод

A custom validator is found if it follows the naming convention "Replace '\Model\' by '\Validator\' and append 'Validator'". If found, it will be added to the $conjunctionValidator. In addition canValidate() will be called on all implementations of the ObjectValidatorInterface to find all validators that could validate the target. The one with the highest priority will be added as well. If multiple validators have the same priority, which one will be added is not deterministic.
protected addCustomValidators ( string $targetClassName, ConjunctionValidator &$conjunctionValidator ) : null | Neos\Flow\Validation\Validator\ObjectValidatorInterface
$targetClassName string
$conjunctionValidator Neos\Flow\Validation\Validator\ConjunctionValidator
Результат null | Neos\Flow\Validation\Validator\ObjectValidatorInterface

buildBaseValidatorConjunction() защищенный Метод

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 Neos\Foo\Domain\Model\Quux, then the validator will be found if it has the name Neos\Foo\Domain\Validator\QuuxValidator
protected buildBaseValidatorConjunction ( string $indexKey, string $targetClassName, array $validationGroups ) : void
$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
Результат void

buildMethodArgumentsValidatorConjunctions() публичный Метод

Detects and registers any validators for arguments: - by the data type specified in the param annotations - additional validators specified in the validate annotations of a method
public buildMethodArgumentsValidatorConjunctions ( string $className, string $methodName, array $methodParameters = null, array $methodValidateAnnotations = null ) : array
$className string
$methodName string
$methodParameters array Optional pre-compiled array of method parameters
$methodValidateAnnotations array Optional pre-compiled array of validate annotations (as array)
Результат array An Array of ValidatorConjunctions for each method parameters.

buildSubObjectValidator() защищенный Метод

Builds a chain of nested object validators by specification of the given object path.
protected buildSubObjectValidator ( array $objectPath, Neos\Flow\Validation\Validator\ValidatorInterface $propertyValidator ) : GenericObjectValidator
$objectPath array The object path
$propertyValidator Neos\Flow\Validation\Validator\ValidatorInterface The validator which should be added to the property specified by objectPath
Результат Neos\Flow\Validation\Validator\GenericObjectValidator

createValidator() публичный Метод

Get a validator for a given data type. Returns a validator implementing the ValidatorInterface or NULL if no validator could be resolved.
public createValidator ( string $validatorType, array $validatorOptions = [] ) : Neos\Flow\Validation\Validator\ValidatorInterface
$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
Результат Neos\Flow\Validation\Validator\ValidatorInterface

getBaseValidatorConjunction() публичный Метод

If no validation is necessary, the returned validator is empty.
public getBaseValidatorConjunction ( string $targetClassName, array $validationGroups = ['Default'] ) : ConjunctionValidator
$targetClassName string Fully qualified class name of the target class, ie. the class which should be validated
$validationGroups array The validation groups to build the validator for
Результат Neos\Flow\Validation\Validator\ConjunctionValidator The validator conjunction

getPolyTypeObjectValidatorImplementationClassNames() публичный статический Метод

Returns a map of object validator class names.
public static getPolyTypeObjectValidatorImplementationClassNames ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
Результат array Array of object validator class names

getValidatorImplementationClassNames() публичный статический Метод

Returns all class names implementing the ValidatorInterface.
public static getValidatorImplementationClassNames ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
Результат array Array of class names implementing ValidatorInterface indexed by class name

getValidatorType() защищенный Метод

Used to map PHP types to validator types.
protected getValidatorType ( string $type ) : string
$type string Data type to unify
Результат string unified data type

reset() публичный Метод

Resets the baseValidatorConjunctions It is usually not required to reset the ValidatorResolver during one request. This method is mainly useful for functional tests
public reset ( ) : void
Результат void

resolveValidatorObjectName() защищенный Метод

Returns the class name of an appropriate validator for the given type. If no validator is available FALSE is returned
protected resolveValidatorObjectName ( string $validatorType ) : string | boolean
$validatorType string Either the fully qualified class name of the validator or the short name of a built-in validator
Результат string | boolean Class name of the validator or FALSE if not available

Описание свойств

$baseValidatorConjunctions защищенное свойство

protected array $baseValidatorConjunctions
Результат array

$objectManager защищенное свойство

protected ObjectManagerInterface,Neos\Flow\ObjectManagement $objectManager
Результат Neos\Flow\ObjectManagement\ObjectManagerInterface

$reflectionService защищенное свойство

protected ReflectionService,Neos\Flow\Reflection $reflectionService
Результат Neos\Flow\Reflection\ReflectionService