bundles/BlockManagerBundle/Controller/API/V1/BlockCollection/AddItems.php
private function validateAddItems(Block $block, string $collectionIdentifier, $items): void
    {
        $this->validate(
            $items,
            [
                new Constraints\Type(['type' => 'array']),
                new Constraints\NotBlank(),
                new Constraints\All(
                    [
                        'constraints' => new Constraints\Collection(
                            [
                                'fields' => [
                                    'value' => [
                                        new Constraints\NotNull(),
                                        new Constraints\Type(['type' => 'scalar']),
                                    ],
                                    'value_type' => [
                                        new Constraints\NotBlank(),
                                        new Constraints\Type(['type' => 'string']),
                                    ],
                                    'position' => new Constraints\Optional(
                                        [
                                            new Constraints\NotNull(),
                                            new Constraints\Type(['type' => 'int']),
                                        ]
                                    ),
                                ],
                            ]
                        ),
                    ]
                ),
            ],
            'items'
        );

        $blockDefinition = $block->getDefinition();
        if (!$blockDefinition->hasCollection($collectionIdentifier)) {
            return;
        }

        $collectionConfig = $blockDefinition->getCollection($collectionIdentifier);

        foreach ($items as $item) {
            if (!$collectionConfig->isValidItemType($item['value_type'])) {
                throw ValidationException::validationFailed(
                    'value_type',
                    sprintf(
                        'Value type "%s" is not allowed in selected block.',
                        $item['value_type']
                    )
                );
            }
        }
    }
private function validateAddItems(Block $block, string $collectionIdentifier, $items): void
    {
        $this->validate(
            $items,
            [
                new Constraints\Type(['type' => 'array']),
                new Constraints\NotBlank(),
                new Constraints\All(
                    [
                        'constraints' => new Constraints\Collection(
                            [
                                'fields' => [
                                    'value' => [
                                        new Constraints\NotNull(),
                                        new Constraints\Type(['type' => 'scalar']),
                                    ],
                                    'value_type' => [
                                        new Constraints\NotBlank(),
                                        new Constraints\Type(['type' => 'string']),
                                    ],
                                    'position' => new Constraints\Optional(
                                        [
                                            new Constraints\NotNull(),
                                            new Constraints\Type(['type' => 'int']),
                                        ]
                                    ),
                                ],
                            ]
                        ),
                    ]
                ),
            ],
            'items'
        );

        $blockDefinition = $block->getDefinition();
        if (!$blockDefinition->hasCollection($collectionIdentifier)) {
            return;
        }

        $collectionConfig = $blockDefinition->getCollection($collectionIdentifier);

        foreach ($items as $item) {
            if (!$collectionConfig->isValidItemType($item['value_type'])) {
                throw ValidationException::validationFailed(
                    'value_type',
                    sprintf(
                        'Value type "%s" is not allowed in selected block.',
                        $item['value_type']
                    )
                );
            }
        }
    }
private function validateAddItems ( Block $ block , string $ collectionIdentifier , $ items ) : void { $ this -> validate ( $ items , [ new Constraints \ Type ( [ 'type' => 'array' ] ) , new Constraints \ NotBlank ( ) , new Constraints \ All ( [ 'constraints' => new Constraints \ Collection ( [ 'fields' => [ 'value' => [ new Constraints \ NotNull ( ) , new Constraints \ Type ( [ 'type' => 'scalar' ] ) , ] , 'value_type' => [ new Constraints \ NotBlank ( ) , new Constraints \ Type ( [ 'type' => 'string' ] ) , ] , 'position' => new Constraints \ Optional ( [ new Constraints \ NotNull ( ) , new Constraints \ Type ( [ 'type' => 'int' ] ) , ] ) , ] , ] ) , ] ) , ] , 'items' ) ; $ blockDefinition = $ block -> getDefinition ( ) ; if ( ! $ blockDefinition -> hasCollection ( $ collectionIdentifier ) ) { return ; } $ collectionConfig = $ blockDefinition -> getCollection ( $ collectionIdentifier ) ; foreach ( $ items as $ item ) { if ( ! $ collectionConfig -> isValidItemType ( $ item [ 'value_type' ] ) ) { throw ValidationException :: validationFailed ( 'value_type' , sprintf ( 'Value type "%s" is not allowed in selected block.' , $ item [ 'value_type' ] ) ) ; } } }
Validates item creation parameters from the request.

@param \Netgen\BlockManager\API\Values\Block\Block $block
@param string $collectionIdentifier
@param mixed $items
Validates item creation parameters from the request .