src/Graviton/DocumentBundle/DependencyInjection/Compiler/Utils/DocumentMap.php
public function getFieldNamesFlat(
        Document $document,
        $documentPrefix = '',
        $exposedPrefix = '',
        callable $callback = null,
        $returnFullField = false
    ) {
        $result = [];
        foreach ($document->getFields() as $field) {
            if ($this->getFlatFieldCheckCallback($field, $callback)) {
                if ($returnFullField) {
                    $setValue = $field;
                } else {
                    $setValue = $exposedPrefix . $field->getExposedName();
                }
                $result[$documentPrefix . $field->getFieldName()] = $setValue;
            }

            if ($field instanceof ArrayField) {
                if ($this->getFlatFieldCheckCallback($field, $callback)) {
                    if ($returnFullField) {
                        $setValue = $field;
                    } else {
                        $setValue = $exposedPrefix . $field->getExposedName() . '.0';
                    }
                    $result[$documentPrefix . $field->getFieldName() . '.0'] = $setValue;
                }
            } elseif ($field instanceof EmbedOne) {
                $result = array_merge(
                    $result,
                    $this->getFieldNamesFlat(
                        $field->getDocument(),
                        $documentPrefix.$field->getFieldName().'.',
                        $exposedPrefix.$field->getExposedName().'.',
                        $callback,
                        $returnFullField
                    )
                );
            } elseif ($field instanceof EmbedMany) {
                if ($this->getFlatFieldCheckCallback($field, $callback)) {
                    if ($returnFullField) {
                        $setValue = $field;
                    } else {
                        $setValue = $exposedPrefix . $field->getExposedName() . '.0';
                    }
                    $result[$documentPrefix . $field->getFieldName() . '.0'] = $setValue;
                }
                $result = array_merge(
                    $result,
                    $this->getFieldNamesFlat(
                        $field->getDocument(),
                        $documentPrefix.$field->getFieldName().'.0.',
                        $exposedPrefix.$field->getExposedName().'.0.',
                        $callback,
                        $returnFullField
                    )
                );
            }
        }

        return $result;
    }
public function getFieldNamesFlat(
        Document $document,
        $documentPrefix = '',
        $exposedPrefix = '',
        callable $callback = null,
        $returnFullField = false
    ) {
        $result = [];
        foreach ($document->getFields() as $field) {
            if ($this->getFlatFieldCheckCallback($field, $callback)) {
                if ($returnFullField) {
                    $setValue = $field;
                } else {
                    $setValue = $exposedPrefix . $field->getExposedName();
                }
                $result[$documentPrefix . $field->getFieldName()] = $setValue;
            }

            if ($field instanceof ArrayField) {
                if ($this->getFlatFieldCheckCallback($field, $callback)) {
                    if ($returnFullField) {
                        $setValue = $field;
                    } else {
                        $setValue = $exposedPrefix . $field->getExposedName() . '.0';
                    }
                    $result[$documentPrefix . $field->getFieldName() . '.0'] = $setValue;
                }
            } elseif ($field instanceof EmbedOne) {
                $result = array_merge(
                    $result,
                    $this->getFieldNamesFlat(
                        $field->getDocument(),
                        $documentPrefix.$field->getFieldName().'.',
                        $exposedPrefix.$field->getExposedName().'.',
                        $callback,
                        $returnFullField
                    )
                );
            } elseif ($field instanceof EmbedMany) {
                if ($this->getFlatFieldCheckCallback($field, $callback)) {
                    if ($returnFullField) {
                        $setValue = $field;
                    } else {
                        $setValue = $exposedPrefix . $field->getExposedName() . '.0';
                    }
                    $result[$documentPrefix . $field->getFieldName() . '.0'] = $setValue;
                }
                $result = array_merge(
                    $result,
                    $this->getFieldNamesFlat(
                        $field->getDocument(),
                        $documentPrefix.$field->getFieldName().'.0.',
                        $exposedPrefix.$field->getExposedName().'.0.',
                        $callback,
                        $returnFullField
                    )
                );
            }
        }

        return $result;
    }
public function getFieldNamesFlat ( Document $ document , $ documentPrefix = '' , $ exposedPrefix = '' , callable $ callback = null , $ returnFullField = false ) { $ result = [ ] ; foreach ( $ document -> getFields ( ) as $ field ) { if ( $ this -> getFlatFieldCheckCallback ( $ field , $ callback ) ) { if ( $ returnFullField ) { $ setValue = $ field ; } else { $ setValue = $ exposedPrefix . $ field -> getExposedName ( ) ; } $ result [ $ documentPrefix . $ field -> getFieldName ( ) ] = $ setValue ; } if ( $ field instanceof ArrayField ) { if ( $ this -> getFlatFieldCheckCallback ( $ field , $ callback ) ) { if ( $ returnFullField ) { $ setValue = $ field ; } else { $ setValue = $ exposedPrefix . $ field -> getExposedName ( ) . '.0' ; } $ result [ $ documentPrefix . $ field -> getFieldName ( ) . '.0' ] = $ setValue ; } } elseif ( $ field instanceof EmbedOne ) { $ result = array_merge ( $ result , $ this -> getFieldNamesFlat ( $ field -> getDocument ( ) , $ documentPrefix . $ field -> getFieldName ( ) . '.' , $ exposedPrefix . $ field -> getExposedName ( ) . '.' , $ callback , $ returnFullField ) ) ; } elseif ( $ field instanceof EmbedMany ) { if ( $ this -> getFlatFieldCheckCallback ( $ field , $ callback ) ) { if ( $ returnFullField ) { $ setValue = $ field ; } else { $ setValue = $ exposedPrefix . $ field -> getExposedName ( ) . '.0' ; } $ result [ $ documentPrefix . $ field -> getFieldName ( ) . '.0' ] = $ setValue ; } $ result = array_merge ( $ result , $ this -> getFieldNamesFlat ( $ field -> getDocument ( ) , $ documentPrefix . $ field -> getFieldName ( ) . '.0.' , $ exposedPrefix . $ field -> getExposedName ( ) . '.0.' , $ callback , $ returnFullField ) ) ; } } return $ result ; }
Gets an array of all fields, flat with full internal name in dot notation as key and
the exposed field name as value. You can pass a callable to limit the fields return a subset of fields.
If the callback returns true, the field will be included in the output. You will get the field definition
passed to your callback.

@param Document $document        The document
@param string   $documentPrefix  Document field prefix
@param string   $exposedPrefix   Exposed field prefix
@param callable $callback        An optional callback where you can influence the number of fields returned
@param boolean  $returnFullField if true, the function returns the full field object instead of the full path

@return array
Gets an array of all fields flat with full internal name in dot notation as key and the exposed field name as value . You can pass a callable to limit the fields return a subset of fields . If the callback returns true the field will be included in the output . You will get the field definition passed to your callback .