src/Configuration/Parser/ContentTypesParser.php
/**
     * Parse a Content Type's field and determine the grouping.
     *
     * @throws ConfigurationException
     */
Parse a Content Type's field and determine the grouping.
Parse a Content Type ' s field and determine the grouping .
protected function parseFieldsAndGroups(array $fields): array
    {
        $currentGroup = 'content';
        $groups = [];
        $acceptFileTypes = $this->generalConfig->get('accept_file_types');
        if (! isset($fields['slug'])) {
            $fields['slug'] = [
                'type' => 'slug',
                'hidden' => true,
            ];
        }
        foreach ($fields as $key => $field) {
            $this->parseField($key, $field, $acceptFileTypes, $currentGroup);
            $fields[$key] = new FieldType($field, $key);
            $groups[$currentGroup] = $currentGroup;
            if (isset($field['fields'])) {
                $fields[$key] = $this->parseFieldRepeaters($fields[$key], $acceptFileTypes, $currentGroup);
                if ($fields[$key] === null) {
                    unset($fields[$key]);
                }
            }
        }
        if (! isset($fields['slug']['uses'])) {
            $fields['slug']['uses'] = key($fields);
        }
        $fields['slug']['uses'] = (array) $fields['slug']['uses'];
        $fields['slug']['type'] = 'slug';
        return [$fields, $groups];
    }
protected function parseFieldsAndGroups ( array $ fields ) : array { $ currentGroup = 'content' ; $ groups = [ ] ; $ acceptFileTypes = $ this -> generalConfig -> get ( 'accept_file_types' ) ; if ( ! isset ( $ fields [ 'slug' ] ) ) { $ fields [ 'slug' ] = [ 'type' => 'slug' , 'hidden' => true , ] ; } foreach ( $ fields as $ key => $ field ) { $ this -> parseField ( $ key , $ field , $ acceptFileTypes , $ currentGroup ) ; $ fields [ $ key ] = new FieldType ( $ field , $ key ) ; $ groups [ $ currentGroup ] = $ currentGroup ; if ( isset ( $ field [ 'fields' ] ) ) { $ fields [ $ key ] = $ this -> parseFieldRepeaters ( $ fields [ $ key ] , $ acceptFileTypes , $ currentGroup ) ; if ( $ fields [ $ key ] === null ) { unset ( $ fields [ $ key ] ) ; } } } if ( ! isset ( $ fields [ 'slug' ] [ 'uses' ] ) ) { $ fields [ 'slug' ] [ 'uses' ] = key ( $ fields ) ; } $ fields [ 'slug' ] [ 'uses' ] = ( array ) $ fields [ 'slug' ] [ 'uses' ] ; $ fields [ 'slug' ] [ 'type' ] = 'slug' ; return [ $ fields , $ groups ] ; }
Parse a Content Type's field and determine the grouping.
Parse a Content Type ' s field and determine the grouping .
// Default group name, if none was specified // Even if there's no `slug` defined, we still want to have one. We mark // it as 'hidden', so we don't show it when editing the Content // Convert array into FieldType // Repeating fields checks // Make sure the slug's `uses` is set // Make sure the `uses` of the slug is an array.