src/Graviton/GeneratorBundle/Command/GenerateDynamicBundleCommand.php
protected function getSubResources(JsonDefinition $definition)
    {
        $resources = [];
        foreach ($definition->getFields() as $field) {
            while ($field instanceof JsonDefinitionArray) {
                $field = $field->getElement();
            }
            if (!$field instanceof JsonDefinitionHash) {
                continue;
            }

            $subDefiniton = $field->getJsonDefinition();

            $resources = array_merge($this->getSubResources($subDefiniton), $resources);
            $resources[] = $subDefiniton;
        }

        return $resources;
    }
protected function getSubResources(JsonDefinition $definition)
    {
        $resources = [];
        foreach ($definition->getFields() as $field) {
            while ($field instanceof JsonDefinitionArray) {
                $field = $field->getElement();
            }
            if (!$field instanceof JsonDefinitionHash) {
                continue;
            }

            $subDefiniton = $field->getJsonDefinition();

            $resources = array_merge($this->getSubResources($subDefiniton), $resources);
            $resources[] = $subDefiniton;
        }

        return $resources;
    }
protected function getSubResources ( JsonDefinition $ definition ) { $ resources = [ ] ; foreach ( $ definition -> getFields ( ) as $ field ) { while ( $ field instanceof JsonDefinitionArray ) { $ field = $ field -> getElement ( ) ; } if ( ! $ field instanceof JsonDefinitionHash ) { continue ; } $ subDefiniton = $ field -> getJsonDefinition ( ) ; $ resources = array_merge ( $ this -> getSubResources ( $ subDefiniton ) , $ resources ) ; $ resources [ ] = $ subDefiniton ; } return $ resources ; }
Get all sub hashes

@param JsonDefinition $definition Main JSON definition
@return JsonDefinition[]
Get all sub hashes