src/Graviton/GeneratorBundle/Definition/JsonDefinition.php
public function getFields()
    {
        $hierarchy = [];
        foreach ($this->def->getTarget()->getFields() as $field) {
            $hierarchy = array_merge_recursive(
                $hierarchy,
                $this->createFieldHierarchyRecursive($field, $field->getName())
            );
        }

        $fields = [];

        /*******
         * CONDITIONAL GENERATED FIELD AREA
         *
         * so simplify things, you can put fields here that should be conditionally created by Graviton.
         * @TODO refactor into a FieldBuilder* type of thing where different builders can add fields conditionally.
         */

        // Versioning field, for version control.
        if ($this->def->getService() && $this->def->getService()->getVersioning()) {
            $definition = new Schema\Field();
            $constraint = new Constraint();
            $constraint->setName('versioning');
            $definition->setName(VersionServiceConstraint::FIELD_NAME)->setTitle('Version')->setType('int')
                       ->setConstraints([$constraint])
                       ->setDescription('Document version. You need to send current version if you want to update.');
            $fields['version'] = $this->processSimpleField('version',  $definition);
        }

        /*******
         * add fields as defined in the definition file.
         */

        foreach ($hierarchy as $name => $definition) {
            $fields[$name] = $this->processFieldHierarchyRecursive($name, $definition);
        }

        return $fields;
    }
public function getFields()
    {
        $hierarchy = [];
        foreach ($this->def->getTarget()->getFields() as $field) {
            $hierarchy = array_merge_recursive(
                $hierarchy,
                $this->createFieldHierarchyRecursive($field, $field->getName())
            );
        }

        $fields = [];

        /*******
         * CONDITIONAL GENERATED FIELD AREA
         *
         * so simplify things, you can put fields here that should be conditionally created by Graviton.
         * @TODO refactor into a FieldBuilder* type of thing where different builders can add fields conditionally.
         */

        // Versioning field, for version control.
        if ($this->def->getService() && $this->def->getService()->getVersioning()) {
            $definition = new Schema\Field();
            $constraint = new Constraint();
            $constraint->setName('versioning');
            $definition->setName(VersionServiceConstraint::FIELD_NAME)->setTitle('Version')->setType('int')
                       ->setConstraints([$constraint])
                       ->setDescription('Document version. You need to send current version if you want to update.');
            $fields['version'] = $this->processSimpleField('version',  $definition);
        }

        /*******
         * add fields as defined in the definition file.
         */

        foreach ($hierarchy as $name => $definition) {
            $fields[$name] = $this->processFieldHierarchyRecursive($name, $definition);
        }

        return $fields;
    }
public function getFields ( ) { $ hierarchy = [ ] ; foreach ( $ this -> def -> getTarget ( ) -> getFields ( ) as $ field ) { $ hierarchy = array_merge_recursive ( $ hierarchy , $ this -> createFieldHierarchyRecursive ( $ field , $ field -> getName ( ) ) ) ; } $ fields = [ ] ; /*******
         * CONDITIONAL GENERATED FIELD AREA
         *
         * so simplify things, you can put fields here that should be conditionally created by Graviton.
         * @TODO refactor into a FieldBuilder* type of thing where different builders can add fields conditionally.
         */ // Versioning field, for version control. if ( $ this -> def -> getService ( ) && $ this -> def -> getService ( ) -> getVersioning ( ) ) { $ definition = new Schema \ Field ( ) ; $ constraint = new Constraint ( ) ; $ constraint -> setName ( 'versioning' ) ; $ definition -> setName ( VersionServiceConstraint :: FIELD_NAME ) -> setTitle ( 'Version' ) -> setType ( 'int' ) -> setConstraints ( [ $ constraint ] ) -> setDescription ( 'Document version. You need to send current version if you want to update.' ) ; $ fields [ 'version' ] = $ this -> processSimpleField ( 'version' , $ definition ) ; } /*******
         * add fields as defined in the definition file.
         */ foreach ( $ hierarchy as $ name => $ definition ) { $ fields [ $ name ] = $ this -> processFieldHierarchyRecursive ( $ name , $ definition ) ; } return $ fields ; }
Returns the field definition

@return DefinitionElementInterface[] Fields
Returns the field definition