src/Graviton/DocumentBundle/DependencyInjection/Compiler/Utils/DocumentMap.php
private function loadSchemaClassMap(Finder $finder)
    {
        $classMap = [];
        foreach ($finder as $file) {
            $schema = json_decode(file_get_contents($file), true);

            if (!isset($schema['x-documentClass'])) {
                continue;
            }

            foreach ($schema['required'] as $field) {
                $classMap[$schema['x-documentClass']][$field]['required'] = true;
            }
            foreach ($schema['searchable'] as $field) {
                $classMap[$schema['x-documentClass']][$field]['searchable'] = 1;
            }
            foreach ($schema['readOnlyFields'] as $field) {
                $classMap[$schema['x-documentClass']][$field]['readOnly'] = true;
            }

            // flags from fields
            if (is_array($schema['properties'])) {
                foreach ($schema['properties'] as $fieldName => $field) {
                    if (isset($field['recordOriginException']) && $field['recordOriginException'] == true) {
                        $classMap[$schema['x-documentClass']][$fieldName]['recordOriginException'] = true;
                    }
                    if (isset($field['x-restrictions'])) {
                        $classMap[$schema['x-documentClass']][$fieldName]['restrictions'] = $field['x-restrictions'];
                    } else {
                        $classMap[$schema['x-documentClass']][$fieldName]['restrictions'] = [];
                    }
                }
            }

            if (isset($schema['solr']) && is_array($schema['solr']) && !empty($schema['solr'])) {
                $classMap[$schema['x-documentClass']]['_base']['solr'] = $schema['solr'];
            } else {
                $classMap[$schema['x-documentClass']]['_base']['solr'] = [];
            }
        }

        return $classMap;
    }
private function loadSchemaClassMap(Finder $finder)
    {
        $classMap = [];
        foreach ($finder as $file) {
            $schema = json_decode(file_get_contents($file), true);

            if (!isset($schema['x-documentClass'])) {
                continue;
            }

            foreach ($schema['required'] as $field) {
                $classMap[$schema['x-documentClass']][$field]['required'] = true;
            }
            foreach ($schema['searchable'] as $field) {
                $classMap[$schema['x-documentClass']][$field]['searchable'] = 1;
            }
            foreach ($schema['readOnlyFields'] as $field) {
                $classMap[$schema['x-documentClass']][$field]['readOnly'] = true;
            }

            // flags from fields
            if (is_array($schema['properties'])) {
                foreach ($schema['properties'] as $fieldName => $field) {
                    if (isset($field['recordOriginException']) && $field['recordOriginException'] == true) {
                        $classMap[$schema['x-documentClass']][$fieldName]['recordOriginException'] = true;
                    }
                    if (isset($field['x-restrictions'])) {
                        $classMap[$schema['x-documentClass']][$fieldName]['restrictions'] = $field['x-restrictions'];
                    } else {
                        $classMap[$schema['x-documentClass']][$fieldName]['restrictions'] = [];
                    }
                }
            }

            if (isset($schema['solr']) && is_array($schema['solr']) && !empty($schema['solr'])) {
                $classMap[$schema['x-documentClass']]['_base']['solr'] = $schema['solr'];
            } else {
                $classMap[$schema['x-documentClass']]['_base']['solr'] = [];
            }
        }

        return $classMap;
    }
private function loadSchemaClassMap ( Finder $ finder ) { $ classMap = [ ] ; foreach ( $ finder as $ file ) { $ schema = json_decode ( file_get_contents ( $ file ) , true ) ; if ( ! isset ( $ schema [ 'x-documentClass' ] ) ) { continue ; } foreach ( $ schema [ 'required' ] as $ field ) { $ classMap [ $ schema [ 'x-documentClass' ] ] [ $ field ] [ 'required' ] = true ; } foreach ( $ schema [ 'searchable' ] as $ field ) { $ classMap [ $ schema [ 'x-documentClass' ] ] [ $ field ] [ 'searchable' ] = 1 ; } foreach ( $ schema [ 'readOnlyFields' ] as $ field ) { $ classMap [ $ schema [ 'x-documentClass' ] ] [ $ field ] [ 'readOnly' ] = true ; } // flags from fields if ( is_array ( $ schema [ 'properties' ] ) ) { foreach ( $ schema [ 'properties' ] as $ fieldName => $ field ) { if ( isset ( $ field [ 'recordOriginException' ] ) && $ field [ 'recordOriginException' ] == true ) { $ classMap [ $ schema [ 'x-documentClass' ] ] [ $ fieldName ] [ 'recordOriginException' ] = true ; } if ( isset ( $ field [ 'x-restrictions' ] ) ) { $ classMap [ $ schema [ 'x-documentClass' ] ] [ $ fieldName ] [ 'restrictions' ] = $ field [ 'x-restrictions' ] ; } else { $ classMap [ $ schema [ 'x-documentClass' ] ] [ $ fieldName ] [ 'restrictions' ] = [ ] ; } } } if ( isset ( $ schema [ 'solr' ] ) && is_array ( $ schema [ 'solr' ] ) && ! empty ( $ schema [ 'solr' ] ) ) { $ classMap [ $ schema [ 'x-documentClass' ] ] [ '_base' ] [ 'solr' ] = $ schema [ 'solr' ] ; } else { $ classMap [ $ schema [ 'x-documentClass' ] ] [ '_base' ] [ 'solr' ] = [ ] ; } } return $ classMap ; }
Load schema class map

@param Finder $finder Mapping finder
@return array
Load schema class map