src/Configuration/Parser/ContentTypesParser.php
/**
     * Basic validation of repeater fields.
     *
     * @throws ConfigurationException
     */
Basic validation of repeater fields.
Basic validation of repeater fields .
private function parseFieldRepeaters(FieldType $repeater, $acceptFileTypes, $currentGroup): ?FieldType
    {
        $blacklist = ['repeater', 'slug', 'templatefield', 'templateselect'];
        $whitelist = ['collection', 'set'];
        if (! isset($repeater['fields']) || ! is_array($repeater['fields']) || ! in_array($repeater['type'], $whitelist, true)) {
            return null;
        }
        $parsedRepeaterFields = [];
        foreach ($repeater['fields'] as $repeaterKey => $repeaterField) {
            if (isset($repeaterField['fields'])) {
                $repeaterField = new FieldType($repeaterField, $repeaterKey);
                $this->parseFieldRepeaters($repeaterField, $acceptFileTypes, $currentGroup);
            }
            $this->parseField($repeaterKey, $repeaterField, $acceptFileTypes, $currentGroup);
            if (isset($repeaterField['type']) && ! in_array($repeaterField['type'], $blacklist, true)) {
                $parsedRepeaterFields[$repeaterKey] = $repeaterField;
            }
        }
        $repeater['fields'] = $parsedRepeaterFields;
        return $repeater;
    }
private function parseFieldRepeaters ( FieldType $ repeater , $ acceptFileTypes , $ currentGroup ) : ? FieldType { $ blacklist = [ 'repeater' , 'slug' , 'templatefield' , 'templateselect' ] ; $ whitelist = [ 'collection' , 'set' ] ; if ( ! isset ( $ repeater [ 'fields' ] ) || ! is_array ( $ repeater [ 'fields' ] ) || ! in_array ( $ repeater [ 'type' ] , $ whitelist , true ) ) { return null ; } $ parsedRepeaterFields = [ ] ; foreach ( $ repeater [ 'fields' ] as $ repeaterKey => $ repeaterField ) { if ( isset ( $ repeaterField [ 'fields' ] ) ) { $ repeaterField = new FieldType ( $ repeaterField , $ repeaterKey ) ; $ this -> parseFieldRepeaters ( $ repeaterField , $ acceptFileTypes , $ currentGroup ) ; } $ this -> parseField ( $ repeaterKey , $ repeaterField , $ acceptFileTypes , $ currentGroup ) ; if ( isset ( $ repeaterField [ 'type' ] ) && ! in_array ( $ repeaterField [ 'type' ] , $ blacklist , true ) ) { $ parsedRepeaterFields [ $ repeaterKey ] = $ repeaterField ; } } $ repeater [ 'fields' ] = $ parsedRepeaterFields ; return $ repeater ; }
Basic validation of repeater fields.
Basic validation of repeater fields .