src/Graviton/DocumentBundle/DependencyInjection/Compiler/TranslatableFieldsCompilerPass.php
private function getTranslatableFields(Document $document, $prefix = '')
    {
        $result = [];
        foreach ($document->getFields() as $field) {
            if ($field instanceof Field) {
                if ($field->getType() == 'translatable') {
                    $result[] = $prefix.$field->getExposedName();
                }
            } elseif ($field instanceof EmbedOne) {
                $result = array_merge(
                    $result,
                    $this->getTranslatableFields(
                        $field->getDocument(),
                        $prefix.$field->getExposedName().'.'
                    )
                );
            } elseif ($field instanceof EmbedMany) {
                $result = array_merge(
                    $result,
                    $this->getTranslatableFields(
                        $field->getDocument(),
                        $prefix.$field->getExposedName().'.0.'
                    )
                );
            }
        }

        return $result;
    }
private function getTranslatableFields(Document $document, $prefix = '')
    {
        $result = [];
        foreach ($document->getFields() as $field) {
            if ($field instanceof Field) {
                if ($field->getType() == 'translatable') {
                    $result[] = $prefix.$field->getExposedName();
                }
            } elseif ($field instanceof EmbedOne) {
                $result = array_merge(
                    $result,
                    $this->getTranslatableFields(
                        $field->getDocument(),
                        $prefix.$field->getExposedName().'.'
                    )
                );
            } elseif ($field instanceof EmbedMany) {
                $result = array_merge(
                    $result,
                    $this->getTranslatableFields(
                        $field->getDocument(),
                        $prefix.$field->getExposedName().'.0.'
                    )
                );
            }
        }

        return $result;
    }
private function getTranslatableFields ( Document $ document , $ prefix = '' ) { $ result = [ ] ; foreach ( $ document -> getFields ( ) as $ field ) { if ( $ field instanceof Field ) { if ( $ field -> getType ( ) == 'translatable' ) { $ result [ ] = $ prefix . $ field -> getExposedName ( ) ; } } elseif ( $ field instanceof EmbedOne ) { $ result = array_merge ( $ result , $ this -> getTranslatableFields ( $ field -> getDocument ( ) , $ prefix . $ field -> getExposedName ( ) . '.' ) ) ; } elseif ( $ field instanceof EmbedMany ) { $ result = array_merge ( $ result , $ this -> getTranslatableFields ( $ field -> getDocument ( ) , $ prefix . $ field -> getExposedName ( ) . '.0.' ) ) ; } } return $ result ; }
Get document fields

@param Document $document Document
@param string   $prefix   Field prefix
@return array
Get document fields