Definition at line 13 of file Builder.php.
◆ __construct()
- Parameters
-
\Magento\Framework\Validator\ConstraintFactory | $constraintFactory | |
\Magento\Framework\ValidatorFactory | $validatorFactory | |
\Magento\Framework\Validator\UniversalFactory | $oneValidatorFactory | |
array | $constraints | |
Definition at line 41 of file Builder.php.
53 $this->_constraints = $constraints;
54 $this->_constraintFactory = $constraintFactory;
55 $this->_validatorFactory = $validatorFactory;
56 $this->_oneValidatorFactory = $oneValidatorFactory;
_checkConfigurationCallback(array $configuration, $callbackIsArray)
_checkConfigurationArguments(array $configuration, $argumentsIsArray)
◆ _addConstraintCallback()
Add callback to constraint configuration
- Parameters
-
array | $constraint | |
\Magento\Framework\Validator\Constraint\Option\Callback | $callback | |
- Returns
- array
Definition at line 200 of file Builder.php.
204 if (!array_key_exists(
'callback',
$constraint[
'options'])) {
◆ _addConstraintMethod()
_addConstraintMethod |
( |
array |
$constraint, |
|
|
array |
$configuration |
|
) |
| |
|
protected |
Add method to constraint configuration
- Parameters
-
array | $constraint | |
array | $configuration | |
- Returns
- array
Definition at line 218 of file Builder.php.
220 if (!array_key_exists(
'methods',
$constraint[
'options'])) {
◆ _applyArgumentsCallback()
_applyArgumentsCallback |
( |
array |
$arguments | ) |
|
|
protected |
Apply all argument callback
- Parameters
-
OptionInterface[] | $arguments |
- Returns
- OptionInterface[]
Definition at line 343 of file Builder.php.
346 if (is_array($argument)) {
348 }
elseif ($argument instanceof OptionInterface) {
349 $argument = $argument->getValue();
elseif(isset( $params[ 'redirect_parent']))
_applyArgumentsCallback(array $arguments)
◆ _checkConfigurationArguments()
_checkConfigurationArguments |
( |
array |
$configuration, |
|
|
|
$argumentsIsArray |
|
) |
| |
|
protected |
Check configuration arguments
- Parameters
-
array | $configuration | |
bool | $argumentsIsArray | |
- Returns
- void
- Exceptions
-
Definition at line 67 of file Builder.php.
70 $allowedKeys = [
'arguments',
'callback',
'method',
'methods',
'breakChainOnFailure'];
72 throw new \InvalidArgumentException(
'Configuration has incorrect format');
75 if ($argumentsIsArray) {
87 throw new \InvalidArgumentException(
'Arguments must be an array');
elseif(isset( $params[ 'redirect_parent']))
_checkMethodArguments(array $configuration)
◆ _checkConfigurationCallback()
_checkConfigurationCallback |
( |
array |
$configuration, |
|
|
|
$callbackIsArray |
|
) |
| |
|
protected |
Check configuration callbacks
- Parameters
-
array | $configuration | |
bool | $callbackIsArray | |
- Returns
- void
- Exceptions
-
Definition at line 116 of file Builder.php.
119 if ($callbackIsArray) {
124 foreach ($callbacks as $callback) {
125 if (!$callback instanceof \
Magento\Framework\
Validator\Constraint\Option\Callback) {
126 throw new \InvalidArgumentException(
127 'Callback must be instance of \Magento\Framework\Validator\Constraint\Option\Callback'
◆ _checkMethodArguments()
_checkMethodArguments |
( |
array |
$configuration | ) |
|
|
protected |
Check configuration method arguments
- Parameters
-
- Returns
- void
- Exceptions
-
Definition at line 98 of file Builder.php.
101 throw new \InvalidArgumentException(
'Method has to be passed as string');
104 throw new \InvalidArgumentException(
'Method arguments must be an array');
◆ _createConstraint()
_createConstraint |
( |
array |
$data | ) |
|
|
protected |
Create constraint from data
- Parameters
-
- Returns
- \Magento\Framework\Validator\Constraint
Definition at line 249 of file Builder.php.
253 if (isset(
$data[
'options']) && is_array(
$data[
'options'])) {
254 $this->_configureConstraintValidator($validator,
$data[
'options']);
258 $result = new \Magento\Framework\Validator\Constraint\Property(
264 $result = $this->_constraintFactory->create([
'validator' => $validator,
'alias' =>
$data[
'alias']]);
_createConstraintValidator(array $data)
const CONSTRAINT_TYPE_PROPERTY
◆ _createConstraintValidator()
_createConstraintValidator |
( |
array |
$data | ) |
|
|
protected |
Create constraint validator instance
- Parameters
-
- Returns
- \Magento\Framework\Validator\ValidatorInterface
- Exceptions
-
Definition at line 277 of file Builder.php.
279 $validator = $this->_oneValidatorFactory->create(
282 $data[
'options'][
'arguments']
284 $data[
'options'][
'arguments']
289 if (!$validator instanceof \
Magento\Framework\
Validator\ValidatorInterface) {
290 throw new \InvalidArgumentException(
292 'Constraint class "%s" must implement \Magento\Framework\Validator\ValidatorInterface',
_applyArgumentsCallback(array $arguments)
◆ _createValidatorInstance()
_createValidatorInstance |
( |
| ) |
|
|
protected |
Get validator instance
- Returns
- \Magento\Framework\Validator
Definition at line 149 of file Builder.php.
151 $validator = $this->_validatorFactory->create();
152 foreach ($this->_constraints as $constraintData) {
154 $breakChainOnFailure = !empty($constraintData[
'options'][
'breakChainOnFailure']);
155 $validator->addValidator($this->
_createConstraint($constraintData), $breakChainOnFailure);
_createConstraint(array $data)
◆ addConfiguration()
addConfiguration |
( |
|
$alias, |
|
|
array |
$configuration |
|
) |
| |
Add constraint configuration
- Parameters
-
string | $alias | |
array | $configuration | |
- Returns
- $this
- Exceptions
-
Definition at line 168 of file Builder.php.
elseif(isset( $params[ 'redirect_parent']))
_checkConfigurationCallback(array $configuration, $callbackIsArray)
_checkConfigurationArguments(array $configuration, $argumentsIsArray)
_addConstraintCallback(array $constraint, \Magento\Framework\Validator\Constraint\Option\Callback $callback)
_addConstraintMethod(array $constraint, array $configuration)
◆ addConfigurations()
addConfigurations |
( |
array |
$configurations | ) |
|
Add constraints configuration
- Parameters
-
- Returns
- $this
Definition at line 233 of file Builder.php.
235 foreach ($configurations as
$alias => $concreteConfigs) {
addConfiguration($alias, array $configuration)
◆ createValidator()
Create validator instance and configure it
- Returns
- \Magento\Framework\Validator
Definition at line 139 of file Builder.php.
_createValidatorInstance()
◆ $_constraintFactory
◆ $_constraints
◆ $_oneValidatorFactory
◆ $_validatorFactory
The documentation for this class was generated from the following file: