Algorithim heavily influenced by:
https://github.com/doctrine/data-fixtures/blob/master/lib/Doctrine/Common/DataFixtures/Loader.php
189876
protected function resolveDependencies($builders)
    {
        $builderSequence = array();

        foreach ($builders as $builder) {
            $dependencies = $builder->getDependencies();

            if (!$dependencies) {
                $builderSequence[$builder->getName()] = 0;
                continue;
            }

            foreach ($dependencies as $dependency) {
                if (!isset($this->builders[$dependency])) {
                    throw new \RuntimeException(sprintf(
                        'Builder "%s" has dependency on unknown builder "%s"',
                        $builder->getName(), $dependency
                    ));

                }
            }

            $builderSequence[$builder->getName()] = -1;
        }

        $sequence = 1;
        $lastCount = -1;

        while (($count = count($unsequencedBuilders = $this->getUnsequencedBuilders($builderSequence))) > 0 && $count !== $lastCount) {
            foreach ($unsequencedBuilders as $key => $builderName) {
                $builder = $this->builders[$builderName];
                $dependencies = $builder->getDependencies();
                $unsequencedDependencies = $this->getUnsequencedBuilders($builderSequence, $dependencies);

                if (count($unsequencedDependencies) === 0) {
                    $builderSequence[$builderName] = $sequence++;
                }
            }

            $lastCount = $count;
        }

        if ($count > 0) {
            throw new \RuntimeException(sprintf(
                'There is a circular refernece in the builder chain.'
            ));
        }

        asort($builderSequence);
        $orderedBuilders = array();

        foreach (array_keys($builderSequence) as $builderName) {
            $orderedBuilders[] = $this->builders[$builderName];
        }

        return $orderedBuilders;
    }
677908
private function getAutoGenerateModes()
    {
        $constPrefix = 'AUTOGENERATE_';
        $prefixLen   = strlen($constPrefix);
        $refClass    = new ReflectionClass('Doctrine\Common\Proxy\AbstractProxyFactory');
        $constsArray = $refClass->getConstants();
        $namesArray  = [];
        $valuesArray = [];

        foreach ($constsArray as $key => $value) {
            if (strpos($key, $constPrefix) !== 0) {
                continue;
            }

            $namesArray[]  = substr($key, $prefixLen);
            $valuesArray[] = (int) $value;
        }

        return [
            'names' => $namesArray,
            'values' => $valuesArray,
        ];
    }
764216
function loadSchemaTransformationRules( $schemaType )
    {
        $ini = eZINI::instance( 'dbschema.ini' );

        if ( !$ini )
        {
            eZDebug::writeError( "Error loading $schemaType schema transformation rules" );
            return false;
        }

        $transformationRules = array();

        if ( $ini->hasVariable( $schemaType, 'ColumnNameTranslation' ) )
            $transformationRules['column-name'] = $ini->variable( $schemaType, 'ColumnNameTranslation' );

        if ( $ini->hasVariable( $schemaType, 'ColumnTypeTranslation' ) )
        {
            $transformationRules['column-type'] = $ini->variable( $schemaType, 'ColumnTypeTranslation' );

            // substitute values like "type1;type2" with an appropriate arrays
            if ( is_array( $transformationRules['column-type'] ) )
            {
                foreach ( $transformationRules['column-type'] as $key => $val )
                {
                    $types = explode( ';', $val );
                    $transformationRules['column-type'][$key] = $types;
                }
            }
        }

        $indexTranslations = array();
        if ( $ini->hasVariable( $schemaType, 'IndexTranslation' ) )
        {
            $translations = $ini->variable( $schemaType, 'IndexTranslation' );
            foreach ( $translations as $combinedName => $translation )
            {
                list( $tableName, $indexName ) = explode( '.', $combinedName );
                $indexTranslations[$tableName][$indexName] = array();
                $fields = explode( ';', $translation );
                foreach ( $fields as $field )
                {
                    $entries = explode( '.', $field );
                    $fieldName = $entries[0];
                    $fieldData = array();
                    for ( $i = 1; $i < count( $entries ); ++$i )
                    {
                        list( $metaName, $metaValue ) = explode( '/', $entries[$i], 2 );
                        if ( is_numeric( $metaValue ) )
                            $metaValue = (int)$metaValue;
                        $fieldData[$metaName] = $metaValue;
                    }
                    $indexTranslations[$tableName][$indexName][$fieldName] = $fieldData;
                }
            }
        }
        $transformationRules['index-field'] = $indexTranslations;

        $tableTranslations = array();
        if ( $ini->hasVariable( $schemaType, 'TableOptionTranslation' ) )
        {
            $translations = $ini->variable( $schemaType, 'TableOptionTranslation' );
            foreach ( $translations as $tableName => $optionTexts )
            {
                $tableTranslations[$tableName] = array();
                $options = explode( ';', $optionTexts );
                $optionData = array();
                foreach ( $options as $option )
                {
                    list( $metaName, $metaValue ) = explode( '/', $option, 2 );
                    if ( is_numeric( $metaValue ) )
                        $metaValue = (int)$metaValue;
                    $optionData[$metaName] = $metaValue;
                    $tableTranslations[$tableName] = $optionData;
                }
            }
        }
        $transformationRules['table-option'] = $tableTranslations;

        if ( $ini->hasVariable( $schemaType, 'IndexNameTranslation' ) )
        {
            $tmpIdxNameTranslations = $ini->variable( $schemaType, 'IndexNameTranslation' );

            if ( is_array( $tmpIdxNameTranslations ) )
            {
                foreach ( $tmpIdxNameTranslations as $key => $val )
                {
                    list( $tableName, $genericIdxName ) = explode( '.', $key );
                    $localIdxName = $val;
                    if ( !$tableName || !$genericIdxName || !$localIdxName )
                    {
                        eZDebug::writeWarning( "Malformed index name translation rule: $key => $val" );
                        continue;
                    }
                    $transformationRules['index-name'][] = array( $tableName, $genericIdxName, $localIdxName );

                }
            }
            unset( $tmpIdxNameTranslations );
        }

        if ( $ini->hasVariable( $schemaType, 'ColumnOptionTranslations' ) )
        {
            $transformationRules['column-option'] = array();
            foreach( $ini->variable( $schemaType, 'ColumnOptionTranslations' ) as $key => $val )
            {
                list( $tableName, $colName ) = explode( '.', $key );
                $colOptOverride = $val;
                if ( !$tableName || !$colName || !$colOptOverride )
                {
                    eZDebug::writeWarning( "Malformed column option translation rule: $key => $val" );
                    continue;
                }
                $transformationRules['column-option'][] = array( $tableName, $colName, $colOptOverride );
            }
        }

        // prevent PHP warnings when cycling through the rules
        foreach ( array( 'column-name', 'column-type', 'column-option', 'index-name' ) as $rulesType )
        {
            if( !isset( $transformationRules[$rulesType] ) )
                $transformationRules[$rulesType] = array();
        }

        return $transformationRules;
    }
1311614
private function generatorClassEntity() {

        /* Lista os schemas do banco de dados */
        foreach ($this->oMetadata->getSchemas() as $valueSchema) {

            $tableNames = $this->oMetadata->getTableNames($valueSchema);

            $namespaceSchema = 'Orm\\' . $this->toCamelCase($valueSchema) . '\Entities';

            /* Lista as tabelas do banco de dados */
            foreach ($tableNames as $tableName) {

                $multiPk = $primaryKey = $bodyExchangeArray = null;

                $class = new ClassGenerator();

                $class->setNamespaceName($namespaceSchema);

                $docBlockClass = DocBlockGenerator::fromArray(array(
                            'shortDescription' => 'Classe tipo model da tabela ' . $tableName . ' dentro do schema ' . $valueSchema,
                            'longDescription' => null,
                ));

                $class->setDocBlock($docBlockClass);
                $class->setName($this->toCamelCase($tableName));

                $class->addProperty('DBSCHEMA', $valueSchema, PropertyGenerator::FLAG_STATIC);
                $class->addProperty('DBTABLE', $tableName, PropertyGenerator::FLAG_STATIC);

                foreach ($this->oMetadata->getConstraints($tableName, $valueSchema) as $constraint) {
                    if (!$constraint->hasColumns()) {
                        continue;
                    }

                    if ($constraint->isPrimaryKey()) {
                        $columns = $constraint->getColumns();

                        if (count($columns) > 1) {
                            $multiPk = true;
                            $primaryKey = implode(', ', $columns);
                        } else {
                            $multiPk = false;
                            $primaryKey = $columns[0];
                        }
                        $class->addProperty('MULTIPK', $multiPk, PropertyGenerator::FLAG_STATIC);
                        $class->addProperty('PKCOLUMN', $primaryKey, PropertyGenerator::FLAG_STATIC);
                    }
                }




                /* Cria os metodos setter/getter e as variáveis das colunas da tabela */

                $table = $this->oMetadata->getTable($tableName, $valueSchema);

                /* Lista as colunas da tabela do banco de dados */
                foreach ($table->getColumns() as $column) {

                    $varName = $this->camelCase($column->getName());
                    $class->addProperty($varName, null, PropertyGenerator::FLAG_PRIVATE);

                    $methodGet = 'get' . $this->toCamelCase($column->getName());
                    $methodSet = 'set' . $this->toCamelCase($column->getName());

                    $docBlockSet = DocBlockGenerator::fromArray(array(
                                'shortDescription' => 'Setter da coluna ' . $column->getName(),
                                'longDescription' => null,
                                'tags' => array(
                                    new Tag\ParamTag($varName, $this->prepareSqlTypeDocBlock($column->getDataType())),
                                ),
                    ));

                    $docBlockGet = DocBlockGenerator::fromArray(array(
                                'shortDescription' => 'Getter da coluna ' . $column->getName(),
                                'longDescription' => null,
                                'tags' => array(
                                    new Tag\ReturnTag(array(
                                        'datatype' => $this->prepareSqlTypeDocBlock($column->getDataType()),
                                            )),
                                ),
                    ));

                    $bodyGet = 'return $this->' . $varName . ';';
                    $bodySet = '$this->' . $varName . ' = $' . $this->camelCase($column->getName()) . ';';

                    $class->addMethod($methodSet, array($this->camelCase($column->getName())), MethodGenerator::FLAG_PUBLIC, $bodySet, $docBlockSet);
                    $class->addMethod($methodGet, array(), MethodGenerator::FLAG_PUBLIC, $bodyGet, $docBlockGet);

                    $bodyExchangeArray .= '$this->' . $varName . ' = (isset($data["' . $column->getName() . '"])) ? $data["' . $column->getName() . '"] : null;' . "\n\n";
                }

                $docBlockExchangeArray = DocBlockGenerator::fromArray(array(
                            'shortDescription' => 'Função para settar todos os objetos por meio de array',
                            'longDescription' => null,
                            'tags' => array(
                                new Tag\ParamTag('data', 'array'),
                            ),
                ));
                $class->addMethod('exchangeArray', array('data'), MethodGenerator::FLAG_PUBLIC, $bodyExchangeArray, $docBlockExchangeArray);

                $docBlockGetArrayCopy = DocBlockGenerator::fromArray(array(
                            'shortDescription' => 'Função para retornar os valores por meio de array dos objetos da classe',
                            'longDescription' => null,
                            'tags' => array(
                                new Tag\ReturnTag(array(
                                    'datatype' => 'mixed',
                                        )),
                            ),
                ));
                $class->addMethod('getArrayCopy', array(), MethodGenerator::FLAG_PUBLIC, 'return get_object_vars($this);', $docBlockGetArrayCopy);

                $classCode = "<?php" . PHP_EOL;

                $classCode .= $class->generate();

                /*
                  $idxConstraint = 0;
                  foreach ($this->oMetadata->getConstraints($tableName, $valueSchema) as $constraint) {

                  $typeConstraint = ($constraint->isPrimaryKey()) ? 'pk' : (($constraint->isForeignKey()) ? 'fk' : null);
                  if (!empty($typeConstraint)) {

                  $consName = $constraint->getName();
                  $contraintObj = $this->oMetadata->getConstraint($consName, $tableName, $valueSchema);

                  $constraintColumns = $contraintObj->getColumns();
                  if (count($constraintColumns) > 1) {
                  foreach ($constraintColumns as $valueConsColumns) {
                  $this->aDatabase[$valueSchema][$tableName][$valueConsColumns]['constraints']['type'] = $typeConstraint;
                  if ($typeConstraint === 'fk') {
                  $this->aDatabase[$valueSchema][$tableName][$valueConsColumns]['constraints']['schemaRef'] = $contraintObj->getReferencedTableSchema();
                  $this->aDatabase[$valueSchema][$tableName][$valueConsColumns]['constraints']['tableRef'] = $contraintObj->getReferencedTableName();
                  $this->aDatabase[$valueSchema][$tableName][$valueConsColumns]['constraints']['columnsRef'] = $contraintObj->getReferencedColumns();
                  }
                  }
                  } else {
                  $this->aDatabase[$valueSchema][$tableName][$constraintColumns[0]]['constraints']['type'] = $typeConstraint;
                  if ($typeConstraint === 'fk') {
                  $this->aDatabase[$valueSchema][$tableName][$constraintColumns[0]]['constraints']['schemaRef'] = $contraintObj->getReferencedTableSchema();
                  $this->aDatabase[$valueSchema][$tableName][$constraintColumns[0]]['constraints']['tableRef'] = $contraintObj->getReferencedTableName();
                  $this->aDatabase[$valueSchema][$tableName][$constraintColumns[0]]['constraints']['columnsRef'] = $contraintObj->getReferencedColumns();
                  }
                  }
                  }

                  $idxConstraint++;
                  }
                 * 
                 */
                file_put_contents($this->ormFolder . $this->toCamelCase($valueSchema) . DS . 'Entities' . DS . $this->toCamelCase($tableName) . '.php', $classCode);
                chmod($this->ormFolder . $this->toCamelCase($valueSchema) . DS . 'Entities' . DS . $this->toCamelCase($tableName) . '.php', 0644);

                $this->generatorClassEntityTable($valueSchema, $tableName);
            }


            //gera arquivo por tabela
        }
        return $this;
    }
713100
public static function collectAllInformation()
    {
        /**
         * @var Container $container
         * @var Collector $collector
         * @var Profiler  $profiler
         */
        $container = Ioc::factory();
        $collector = $container->get('debugger.collector');
        $profiler  = $container->get('profiler');

        // Packages
        $packages = PackageHelper::getPackages();
        $pkgs     = [];

        foreach ($packages as $package) {
            $pkgs[$package->getName()] = $package->getDir();
        }

        // Windwalker Information
        $collector['windwalker.version.framework'] = ComposerInformation::getInstalledVersion('windwalker/framework');
        $collector['windwalker.version.core']      = ComposerInformation::getInstalledVersion('windwalker/core');
        $collector['windwalker.config']            = Ioc::getConfig()->toArray();

        // PHP
        $collector['system.php.version']    = PHP_VERSION;
        $collector['system.php.extensions'] = get_loaded_extensions();

        // Load all inputs
        $collector['request'] = Ioc::getInput()->dumpAllInputs();

        // SQL Explain
        if (Ioc::exists('database')) {
            $queries = $collector['database.queries'];
            $db      = Ioc::getDatabase();

            if ($db->getName() === 'mysql') {
                foreach ($queries as $k => $data) {
                    if (stripos(trim($data['query']), 'SELECT') !== 0) {
                        continue;
                    }

                    $query = $db->getQuery(true);
                    $query->setQuery('EXPLAIN ' . $data['query']);

                    if (!empty($data['bounded'])) {
                        foreach ((array) $data['bounded'] as $key => $bind) {
                            $bind = (object) $bind;
                            $query->bind($key, $bind->value, $bind->dataType, $bind->length, $bind->driverOptions);
                        }
                    }

                    $collector['database.queries.' . $k . '.explain'] = $db->prepare($query)->loadAll();
                }
            }

            // Database Information
            $collector['database.driver.name']  = $db->getName();
            $collector['database.driver.class'] = get_class($db);
            $collector['database.info']         = $db->getOptions();

            if ($queries instanceof DataSet) {
                $collector['database.queries'] = iterator_to_array($queries);
            }
        }

        // Events
        /** @var EventDispatcher $dispatcher */
        $dispatcher = $container->get('dispatcher');

        $collector['event.executed'] = $dispatcher->getCollector();

        $listenersMapping = [];

        foreach ($dispatcher->getListeners() as $eventName => $listeners) {
            $listenersMapping[$eventName] = [];

            foreach ($listeners as $listener) {
                if ($listener instanceof \Closure) {
                    continue;
                }

                if (is_object($listener)) {
                    $listener = [get_class($listener), $eventName];
                }

                $listenersMapping[$eventName][] = $listener;
            }
        }

        $collector['event.listeners'] = $listenersMapping;

        // Headers
        $collector['system.http.status']  = $collector['exception'] ? $collector['exception']['code'] : http_response_code();
        $collector['system.http.headers'] = headers_list();
    }
247429
public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder('stof_doctrine_extensions');
        if (\method_exists($treeBuilder, 'getRootNode')) {
            $rootNode = $treeBuilder->getRootNode();
        } else {
            // BC layer for symfony/config 4.1 and older
            $rootNode = $treeBuilder->root('stof_doctrine_extensions');
        }

        $rootNode
            ->append($this->getVendorNode('orm'))
            ->append($this->getVendorNode('mongodb'))
            ->append($this->getClassNode())
            ->append($this->getUploadableNode())
            ->children()
                ->scalarNode('default_locale')
                    ->cannotBeEmpty()
                    ->defaultValue('en')
                ->end()
                ->booleanNode('translation_fallback')->defaultFalse()->end()
                ->booleanNode('persist_default_translation')->defaultFalse()->end()
                ->booleanNode('skip_translation_on_load')->defaultFalse()->end()
            ->end()
        ;

        return $treeBuilder;
    }
1253467
public function inherit() {
    
    if ((bool)Config::getOption("plugins.dataInheritance.enabled")) {
      
      $storeData        = Data::get();
      $storePatternData = PatternData::get();
      
      foreach ($storePatternData as $patternStoreKey => $patternData) {
        
        if (isset($patternData["lineages"]) && (count($patternData["lineages"]) > 0)) {
          
          $dataLineage = array();
          
          foreach($patternData["lineages"] as $lineage) {
            
            // merge the lineage data with the lineage store. newer/higher-level data is more important.
            $lineageKey  = $lineage["lineagePattern"];
            $lineageData = isset($storeData["patternSpecific"][$lineageKey]) && isset($storeData["patternSpecific"][$lineageKey]["data"]) ? $storeData["patternSpecific"][$lineageKey]["data"] : array();
            if (!empty($lineageData)) {
              $dataLineage = array_replace_recursive($dataLineage, $lineageData);
            }
            
          }
          
          // merge the lineage data with the pattern data. pattern data is more important.
          $dataPattern = isset($storeData["patternSpecific"][$patternStoreKey]) && isset($storeData["patternSpecific"][$patternStoreKey]["data"]) ? $storeData["patternSpecific"][$patternStoreKey]["data"] : array();
          $dataPattern = array_replace_recursive($dataLineage, $dataPattern);
          
          if (!empty($dataPattern)) {
            $storeData["patternSpecific"][$patternStoreKey]["data"] = $dataPattern;
          }
          
        }
        
      }
      
      Data::replaceStore($storeData);
      
    }
    
  }
680068
private function getBundleFixtureDirectories()
    {
        return array_filter(
            array_map(
                function ($bundle) {
                    $path = $bundle->getPath() . '/DataFixtures/ORM';

                    return is_dir($path) ? $path : null;
                },
                $this->kernel->getBundles()
            )
        );
    }
75023
public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode    = $treeBuilder->root($this->alias);

        $rootNode
            ->children()
                ->booleanNode('use_doctrine_orm')->defaultFalse()->end()
                ->booleanNode('use_doctrine_odm')->defaultFalse()->end()
                ->booleanNode('use_propel')->defaultFalse()->end()
                ->booleanNode('overwrite_if_exists')->defaultFalse()->end()
                ->scalarNode('base_admin_template')
                    ->defaultValue("AdmingeneratorGeneratorBundle::base_admin.html.twig")
                ->end()
                ->scalarNode('dashboard_welcome_path')->defaultNull()->end()
                ->scalarNode('login_path')->defaultNull()->end()
                ->scalarNode('logout_path')->defaultNull()->end()
                ->scalarNode('exit_path')->defaultNull()->end()
                ->scalarNode('generator_cache')->defaultNull()->end()
                ->arrayNode('twig')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('use_form_resources')->defaultTrue()->end()
                        ->booleanNode('use_localized_date')->defaultFalse()->end()
                        ->scalarNode('date_format')->defaultValue('Y-m-d')->end()
                        ->scalarNode('datetime_format')->defaultValue('Y-m-d H:i:s')->end()
                        ->scalarNode('localized_date_format')->defaultValue('medium')->end()
                        ->scalarNode('localized_datetime_format')->defaultValue('medium')->end()
                        ->arrayNode('number_format')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('decimal')->defaultValue(0)->end()
                                ->scalarNode('decimal_point')->defaultValue('.')->end()
                                ->scalarNode('thousand_separator')->defaultValue(',')->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
                ->arrayNode('templates_dirs')
                    ->useAttributeAsKey('key')
                    ->prototype('scalar')->end()
                ->end()
                ->arrayNode('form_types')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->arrayNode('doctrine_orm')
                            ->addDefaultsIfNotSet()
                            ->children()
                                // datetime types
                                ->scalarNode('datetime')->defaultValue('datetime')->end()
                                ->scalarNode('vardatetime')->defaultValue('datetime')->end()
                                ->scalarNode('datetimetz')->defaultValue('datetime')->end()
                                ->scalarNode('date')->defaultValue('datetime')->end()
                                // time types
                                ->scalarNode('time')->defaultValue('time')->end()
                                // number types
                                ->scalarNode('decimal')->defaultValue('number')->end()
                                ->scalarNode('float')->defaultValue('number')->end()
                                // integer types
                                ->scalarNode('integer')->defaultValue('integer')->end()
                                ->scalarNode('bigint')->defaultValue('integer')->end()
                                ->scalarNode('smallint')->defaultValue('integer')->end()
                                // text types
                                ->scalarNode('string')->defaultValue('text')->end()
                                // textarea types
                                ->scalarNode('text')->defaultValue('textarea')->end()
                                // association types
                                ->scalarNode('entity')->defaultValue('entity')->end()
                                ->scalarNode('collection')->defaultValue('collection')->end()
                                // array types
                                ->scalarNode('array')->defaultValue('collection')->end()
                                // boolean types
                                ->scalarNode('boolean')->defaultValue('checkbox')->end()
                            ->end()
                        ->end()
                        ->arrayNode('doctrine_odm')
                            ->addDefaultsIfNotSet()
                            ->children()
                                // datetime types
                                ->scalarNode('datetime')->defaultValue('datetime')->end()
                                ->scalarNode('timestamp')->defaultValue('datetime')->end()
                                ->scalarNode('vardatetime')->defaultValue('datetime')->end()
                                ->scalarNode('datetimetz')->defaultValue('datetime')->end()
                                ->scalarNode('date')->defaultValue('datetime')->end()
                                // time types
                                ->scalarNode('time')->defaultValue('time')->end()
                                // number types
                                ->scalarNode('decimal')->defaultValue('number')->end()
                                ->scalarNode('float')->defaultValue('number')->end()
                                // integer types
                                ->scalarNode('int')->defaultValue('integer')->end()
                                ->scalarNode('integer')->defaultValue('integer')->end()
                                ->scalarNode('int_id')->defaultValue('integer')->end()
                                ->scalarNode('bigint')->defaultValue('integer')->end()
                                ->scalarNode('smallint')->defaultValue('integer')->end()
                                // text types
                                ->scalarNode('id')->defaultValue('text')->end()
                                ->scalarNode('custom_id')->defaultValue('text')->end()
                                ->scalarNode('string')->defaultValue('text')->end()
                                // textarea types
                                ->scalarNode('text')->defaultValue('textarea')->end()
                                // association types
                                ->scalarNode('document')->defaultValue('document')->end()
                                ->scalarNode('collection')->defaultValue('collection')->end()
                                // hash types
                                ->scalarNode('hash')->defaultValue('collection')->end()
                                // boolean types
                                ->scalarNode('boolean')->defaultValue('checkbox')->end()
                            ->end()
                        ->end()
                        ->arrayNode('propel')
                            ->addDefaultsIfNotSet()
                            ->children()
                                // datetime types
                                ->scalarNode('TIMESTAMP')->defaultValue('datetime')->end()
                                ->scalarNode('BU_TIMESTAMP')->defaultValue('datetime')->end()
                                // date types
                                ->scalarNode('DATE')->defaultValue('date')->end()
                                ->scalarNode('BU_DATE')->defaultValue('date')->end()
                                // time types
                                ->scalarNode('TIME')->defaultValue('time')->end()
                                // number types
                                ->scalarNode('FLOAT')->defaultValue('number')->end()
                                ->scalarNode('REAL')->defaultValue('number')->end()
                                ->scalarNode('DOUBLE')->defaultValue('number')->end()
                                ->scalarNode('DECIMAL')->defaultValue('number')->end()
                                // integer types
                                ->scalarNode('TINYINT')->defaultValue('integer')->end()
                                ->scalarNode('SMALLINT')->defaultValue('integer')->end()
                                ->scalarNode('INTEGER')->defaultValue('integer')->end()
                                ->scalarNode('BIGINT')->defaultValue('integer')->end()
                                ->scalarNode('NUMERIC')->defaultValue('integer')->end()
                                // text types
                                ->scalarNode('CHAR')->defaultValue('text')->end()
                                ->scalarNode('VARCHAR')->defaultValue('text')->end()
                                // textarea types
                                ->scalarNode('LONGVARCHAR')->defaultValue('textarea')->end()
                                ->scalarNode('BLOB')->defaultValue('textarea')->end()
                                ->scalarNode('CLOB')->defaultValue('textarea')->end()
                                ->scalarNode('CLOB_EMU')->defaultValue('textarea')->end()
                                // association types
                                ->scalarNode('model')->defaultValue('model')->end()
                                ->scalarNode('collection')->defaultValue('collection')->end()
                                // array types
                                ->scalarNode('PHP_ARRAY')->defaultValue('collection')->end()
                                // choice types
                                ->scalarNode('ENUM')->defaultValue('choice')->end()
                                // boolean types
                                ->scalarNode('BOOLEAN')->defaultValue('checkbox')->end()
                                ->scalarNode('BOOLEAN_EMU')->defaultValue('checkbox')->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
                ->arrayNode('filter_types')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->arrayNode('doctrine_orm')
                            ->addDefaultsIfNotSet()
                            ->children()
                                // datetime types
                                ->scalarNode('datetime')->end()
                                ->scalarNode('vardatetime')->end()
                                ->scalarNode('datetimetz')->end()
                                ->scalarNode('date')->end()
                                // time types
                                ->scalarNode('time')->end()
                                // number types
                                ->scalarNode('decimal')->end()
                                ->scalarNode('float')->end()
                                // integer types
                                ->scalarNode('integer')->end()
                                ->scalarNode('bigint')->end()
                                ->scalarNode('smallint')->end()
                                // text types
                                ->scalarNode('string')->end()
                                // textarea types
                                ->scalarNode('text')->defaultValue('text')->end()
                                // association types
                                ->scalarNode('entity')->end()
                                ->scalarNode('collection')->defaultValue('entity')->end()
                                // array types
                                ->scalarNode('array')->end()
                                // boolean types
                                ->scalarNode('boolean')->defaultValue('choice')->end()
                            ->end()
                        ->end()
                        ->arrayNode('doctrine_odm')
                            ->addDefaultsIfNotSet()
                            ->children()
                                // datetime types
                                ->scalarNode('datetime')->end()
                                ->scalarNode('timestamp')->end()
                                ->scalarNode('vardatetime')->end()
                                ->scalarNode('datetimetz')->end()
                                ->scalarNode('date')->end()
                                // time types
                                ->scalarNode('time')->end()
                                // number types
                                ->scalarNode('decimal')->end()
                                ->scalarNode('float')->end()
                                // integer types
                                ->scalarNode('int')->end()
                                ->scalarNode('integer')->end()
                                ->scalarNode('int_id')->end()
                                ->scalarNode('bigint')->end()
                                ->scalarNode('smallint')->end()
                                // text types
                                ->scalarNode('id')->end()
                                ->scalarNode('custom_id')->end()
                                ->scalarNode('string')->end()
                                // textarea types
                                ->scalarNode('text')->defaultValue('text')->end()
                                // association types
                                ->scalarNode('document')->end()
                                ->scalarNode('collection')->defaultValue('document')->end()
                                // hash types
                                ->scalarNode('hash')->defaultValue('text')->end()
                                // boolean types
                                ->scalarNode('boolean')->defaultValue('choice')->end()
                            ->end()
                        ->end()
                        ->arrayNode('propel')
                            ->addDefaultsIfNotSet()
                            ->children()
                                // datetime types
                                ->scalarNode('TIMESTAMP')->end()
                                ->scalarNode('BU_TIMESTAMP')->end()
                                // date types
                                ->scalarNode('DATE')->end()
                                ->scalarNode('BU_DATE')->end()
                                // time types
                                ->scalarNode('TIME')->end()
                                // number types
                                ->scalarNode('FLOAT')->end()
                                ->scalarNode('REAL')->end()
                                ->scalarNode('DOUBLE')->end()
                                ->scalarNode('DECIMAL')->end()
                                // integer types
                                ->scalarNode('TINYINT')->end()
                                ->scalarNode('SMALLINT')->end()
                                ->scalarNode('INTEGER')->end()
                                ->scalarNode('BIGINT')->end()
                                ->scalarNode('NUMERIC')->end()
                                // text types
                                ->scalarNode('CHAR')->end()
                                ->scalarNode('VARCHAR')->end()
                                // textarea types
                                ->scalarNode('LONGVARCHAR')->defaultValue('text')->end()
                                ->scalarNode('BLOB')->defaultValue('text')->end()
                                ->scalarNode('CLOB')->defaultValue('text')->end()
                                ->scalarNode('CLOB_EMU')->defaultValue('text')->end()
                                // association types
                                ->scalarNode('model')->end()
                                ->scalarNode('collection')->defaultValue('model')->end()
                                // array types
                                ->scalarNode('PHP_ARRAY')->defaultValue('choice')->end()
                                // choice types
                                ->scalarNode('ENUM')->end()
                                // boolean types
                                ->scalarNode('BOOLEAN')->defaultValue('choice')->end()
                                ->scalarNode('BOOLEAN_EMU')->defaultValue('choice')->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
                ->append($this->getStylesheetNode())
                ->append($this->getJavascriptsNode())
            ->end();

        return $treeBuilder;
    }
1112753
private function processEntityManager()
	{
		$builder = $this->getContainerBuilder();

		$configuration = $builder->addDefinition($this->prefix('configuration'))
			->setClass(Configuration::class)
			->addSetup('$service->setMetadataDriverImpl($this->getService(?))', [$this->prefix('metadata.driver')])
			->addSetup('$service->setMetadataCacheImpl(?)', ['@' . $this->prefix('cache.metadata')])
			->addSetup('$service->setQueryCacheImpl(?)', ['@' . $this->prefix('cache.query')])
			->addSetup('$service->setResultCacheImpl(?)', ['@' . $this->prefix('cache.result')])
			->addSetup('$service->setHydrationCacheImpl(?)', ['@' . $this->prefix('cache.hydration')])
			->addSetup('$service->setProxyDir(?)', [$this->config['proxyDir']])
			->addSetup('$service->setProxyNamespace(?)', [$this->config['proxyNamespace']])
			->addSetup('$service->setNamingStrategy(?)', [new \Nette\DI\Statement('Doctrine\ORM\Mapping\UnderscoreNamingStrategy')])
			->addSetup('$service->setQuoteStrategy(?)', [new \Nette\DI\Statement('Doctrine\ORM\Mapping\DefaultQuoteStrategy')])
			->addSetup('$service->setAutoGenerateProxyClasses(?)', [1])
			->addSetup('$service->setEntityListenerResolver(?)', ['@' . $this->prefix('entityListenerResolver')]);

		$entityManager = $builder->addDefinition($this->prefix('entityManager'))
			->setClass(EntityManager::class)
			->setFactory(EntityManager::class . '::create', [
				'@' . $this->prefix('connection'),
				'@' . $this->prefix('configuration'),
				'@' . $this->prefix('eventManager')
			]);
	}
158848
private function addRelations(Repository $repo, MutableBag $relationQueue, Bag $importDatum, MutableBag $relationFields)
    {
        $classMeta = $repo->getClassMetadata();
        foreach ($relationFields as $fieldName) {
            $relationName = $classMeta->getBoltName() . '/' . $importDatum->get('slug');

            $existing = (array) $relationQueue->get($relationName);
            $relatedEntities = $importDatum->get($fieldName);

            if ($relatedEntities) {
                $relationQueue->set($relationName, array_merge($relatedEntities->toArray(), $existing));
            }
        }
    }
1245532
function load(file, loadDescription) {
            try {
                var data = fs.readFileSync(file, 'utf8');
            
                var regex = /(\/\*\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)/g;
                
                var commentRaw;
                var comments = [];
                var commentParsed;
                var description;
                
                if (loadDescription) {
                    commentRaw = regex.exec(data);
                    commentParsed = doctrine.parse(commentRaw[0], { unwrap: true });
                    description = commentParsed.description;
                } else {
                    description = '';
                }

                while ((commentRaw = regex.exec(data)) !== null) {
                    commentParsed = doctrine.parse(commentRaw[0], { unwrap: true });

                    commentParsed.getMethod = function() {
                        for (var tag of this.tags)
                        {
                            if (tag.title === 'function') {
                                return tag.name;
                            }
                        }
                    };
                    commentParsed.getSummary = function() {
                        for (var tag of this.tags)
                        {
                            if (tag.title === 'summary') {
                                return tag.description.replace(/(\r\n|\n)/gm,'');
                            }
                        }
                    };
                    commentParsed.getDescription = function() {
                        for (var tag of this.tags)
                        {
                            if (tag.title === 'description') {
                                return tag.description.replace(/(?<!  )(\r\n|\n)/gm,''); 
                            }
                        }
                    };
                    // TODO: add support for multiple examples
                    commentParsed.getExample = function() {
                        for (var tag of this.tags)
                        {
                            if (tag.title === 'example') {
                                var example = {
                                    description: tag.description,
                                    caption: tag.caption
                                }
                                return example;
                            }
                        }
                    };
                    commentParsed.getReturn = function() {
                        for (var tag of this.tags)
                        {
                            if (tag.title === 'return') {
                                var type = doctrine.type.stringify(tag.type, {compact:true});
                                type = type.replace(/<|>/ig, function(m){
                                    return '&' + (m == '>' ? 'g' : 'l') + 't;';
                                });

                                return { 
                                    description: tag.description.replace(/(\r\n|\n)/gm,''), 
                                    type: type
                                };
                            }
                        }
                    };
                    commentParsed.getParams = function() {
                        var params = [];
                        for (var tag of this.tags)
                        {
                            if (tag.title === 'param') {
                                var optional;
                                if (tag.type.type === 'OptionalType' || tag.type.type === 'RestType') {
                                    optional = true;
                                } else {
                                    optional = false;
                                }

                                var type = doctrine.type.stringify(tag.type, {compact:true});
                                type = type.replace(/<|>/ig, function(m){
                                    return '&' + (m == '>' ? 'g' : 'l') + 't;';
                                });
                                
                                params.push({ 
                                    description: tag.description.replace(/(\r\n|\n)/gm,''), 
                                    name: tag.name, 
                                    type: type,
                                    optional: optional
                                });
                            }
                        }
                        return params;
                    };
                    commentParsed.getFor = function() {
                        for (var tag of this.tags)
                        {
                            if (tag.title === 'for') {
                                var fors = tag.description.replace(/(\r\n|\n)/gm,'').split(',').map(function(item) {
                                    return item.trim();
                                });
                                return fors;
                            }
                        }
                    };
                    commentParsed.getDeprecated = function() {
                        for (var tag of this.tags)
                        {
                            if (tag.title === 'deprecated') {
                                return 'This command is deprecated and will be removed in the future. ' + tag.description;
                            }
                        }
                    };


                    comments.push(commentParsed);
                }
                return { description: description.replace(/(?<!  )(\r\n|\n)/gm, ''), methods: comments };
            } catch (exc) {       
                grunt.log.error("Unable to load/parse " + file, exc);
            }
        }
1228841
protected function setupMetaData()
    {
        MetaDataManager::registerDrivers(
            $this->config['meta']['drivers'],
            $this->config['dev']
        );

        MetaDataManager::resolved(function (Configuration $configuration) {

            // Debugbar
            if ($this->config['debugbar'] === true) {
                $debugStack = new DebugStack();
                $configuration->setSQLLogger($debugStack);
                $this->app['debugbar']->addCollector(
                    new DoctrineCollector($debugStack)
                );
            }

            $configuration->getMetadataDriverImpl()->addPaths([
                __DIR__ . '/Migrations',
                __DIR__ . '/Auth/Passwords'
            ]);

            // Automatically make table, column names, etc. like Laravel
            $configuration->setNamingStrategy(
                $this->app->make(LaravelNamingStrategy::class)
            );

            // Custom functions
            $configuration->setCustomDatetimeFunctions($this->config['custom_datetime_functions']);
            $configuration->setCustomNumericFunctions($this->config['custom_numeric_functions']);
            $configuration->setCustomStringFunctions($this->config['custom_string_functions']);

            // Second level caching
            if ($this->config['cache']['second_level']) {
                $configuration->setSecondLevelCacheEnabled(true);

                $cacheConfig = $configuration->getSecondLevelCacheConfiguration();
                $cacheConfig->setCacheFactory(
                    new DefaultCacheFactory(
                        $cacheConfig->getRegionsConfiguration(),
                        CacheManager::resolve(
                            $this->config['cache']['default']
                        )
                    )
                );
            }
        });
    }
92127
public function requireTable()
    {
        // Only build the table if we've actually got fields
        $schema = static::getSchema();
        $table = $schema->tableName(static::class);
        $fields = $schema->databaseFields(static::class, false);
        $indexes = $schema->databaseIndexes(static::class, false);
        $extensions = self::database_extensions(static::class);

        if (empty($table)) {
            throw new LogicException(
                "Class " . static::class . " not loaded by manifest, or no database table configured"
            );
        }

        if ($fields) {
            $hasAutoIncPK = get_parent_class($this) === self::class;
            DB::require_table(
                $table,
                $fields,
                $indexes,
                $hasAutoIncPK,
                $this->config()->get('create_table_options'),
                $extensions
            );
        } else {
            DB::dont_require_table($table);
        }

        // Build any child tables for many_many items
        if ($manyMany = $this->uninherited('many_many')) {
            $extras = $this->uninherited('many_many_extraFields');
            foreach ($manyMany as $component => $spec) {
                // Get many_many spec
                $manyManyComponent = $schema->manyManyComponent(static::class, $component);
                $parentField = $manyManyComponent['parentField'];
                $childField = $manyManyComponent['childField'];
                $tableOrClass = $manyManyComponent['join'];

                // Skip if backed by actual class
                if (class_exists($tableOrClass)) {
                    continue;
                }

                // Build fields
                $manymanyFields = array(
                    $parentField => "Int",
                    $childField => "Int",
                );
                if (isset($extras[$component])) {
                    $manymanyFields = array_merge($manymanyFields, $extras[$component]);
                }

                // Build index list
                $manymanyIndexes = [
                    $parentField => [
                        'type' => 'index',
                        'name' => $parentField,
                        'columns' => [$parentField],
                    ],
                    $childField => [
                        'type' => 'index',
                        'name' => $childField,
                        'columns' => [$childField],
                    ],
                ];
                DB::require_table($tableOrClass, $manymanyFields, $manymanyIndexes, true, null, $extensions);
            }
        }

        // Let any extentions make their own database fields
        $this->extend('augmentDatabase', $dummy);
    }
524315
public function createFixtures()
    {
        /**
         * Bundle fixtures
         */
        if($this->container->getParameter('core.fixtures_bundle')){
            $this->runSqlScript('Country.sql');
            $this->runSqlScript('State.sql');
            //$this->runSqlScript('PostalCode.sql');
            $this->runSqlScript('Translation.sql');

            //get dinamic actor class
            $actorClass = $this->container->get('core_manager')->getActorClass();

            $factory = $this->get('security.encoder_factory');
            $encoder = $factory->getEncoder(new $actorClass());

            //Roles
            $userRole = new Role();
            $userRole->setName('user');
            $userRole->setRole(Role::USER);
            $this->getManager()->persist($userRole);

            $managerRole = new Role();
            $managerRole->setName('manager');
            $managerRole->setRole(Role::MANAGER);
            $this->getManager()->persist($managerRole);

            $companyRole = new Role();
            $companyRole->setName('company');
            $companyRole->setRole(Role::COMPANY);
            $this->getManager()->persist($companyRole);

            $adminRole = new Role();
            $adminRole->setName('admin');
            $adminRole->setRole(Role::ADMIN);
            $this->getManager()->persist($adminRole);

            $superRole = new Role();
            $superRole->setName('root');
            $superRole->setRole(Role::SUPER_ADMIN);
            $this->getManager()->persist($superRole);

            $this->getManager()->flush();

             //User root
            $password = 'root';
            $root = new BaseUser();
            $root->setUsername('root');
            $root->setEmail('root@latinotype.com');
            $root->addRole($superRole);
            $encodePassword = $encoder->encodePassword($password, $root->getSalt());
            $root->setPassword($encodePassword);
            $root->setName('Root');
            $root->setActive(true);
            $this->getManager()->persist($root);
            
            $this->getManager()->flush();
            
            /**
             * Add Parameters
             */
            $this->addParameters();

        }
        
        /**
         * Dev fixtures
         */
        if($this->container->getParameter('core.fixtures_dev')){
            //User admin
            $password = 'admin';
            $admin = new $actorClass();
            $admin->setUsername('admin');
            $admin->setEmail('admin@admin.com');
            $admin->addRole($adminRole);
            $encodePassword = $encoder->encodePassword($password, $admin->getSalt());
            $admin->setPassword($encodePassword);
            $admin->setName('Admin');
            $admin->setLastname('Lastname');
            $admin->setActive(true);
            $this->getManager()->persist($admin);

            $password2 = 'company';
            $company = new $actorClass();
            $company->setUsername('company');
            $company->setEmail('company@latinotype.com');
            $company->addRole($companyRole);
            $encodePassword2 = $encoder->encodePassword($password2, $company->getSalt());
            $company->setPassword($encodePassword2);
            $company->setName('Company');
            $company->setLastname('Lastname');
            $company->setActive(true);
            $this->getManager()->persist($company);

            $password = 'user';
            $user = new $actorClass();
            $user->setUsername('user');
            $user->setEmail('user@user.com');
            $user->addRole($userRole);
            $encodePassword = $encoder->encodePassword($password, $user->getSalt());
            $user->setPassword($encodePassword);
            $user->setName('User');
            $user->setLastname('Lastname');
            $user->setActive(true);
            $this->getManager()->persist($user);

            $password2 = 'user2';
            $user2 = new $actorClass();
            $user2->setUsername('user2');
            $user2->setEmail('user2@user2.com');
            $user2->addRole($userRole);
            $encodePassword2 = $encoder->encodePassword($password2, $user2->getSalt());
            $user2->setPassword($encodePassword2);
            $user2->setName('User2');
            $user2->setLastname('Lastname2');
            $user2->setActive(true);
            $this->getManager()->persist($user2);

            $this->getManager()->flush();
        }
        
    }
1373635
public function registerBundles()
    {
        //==============================================================================
        // SYMFONY CORE
        $bundles[] = new Symfony\Bundle\FrameworkBundle\FrameworkBundle();
        $bundles[] = new Symfony\Bundle\SecurityBundle\SecurityBundle();
        $bundles[] = new Symfony\Bundle\TwigBundle\TwigBundle();
        $bundles[] = new Symfony\Bundle\MonologBundle\MonologBundle();

        //==============================================================================
        // DOCTRINE CORE
        $bundles[] = new Doctrine\Bundle\DoctrineBundle\DoctrineBundle();

        //==============================================================================
        // SPLASH PHP BUNDLE
        $bundles[] = new Splash\Bundle\SplashBundle();

        //==============================================================================
        // SPLASH CONNECTORS BUNDLE
        $bundles[] = new Splash\Connectors\Faker\FakerBundle();

        //==============================================================================
        // TEST & DEV BUNDLES
        if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();

            if ('dev' === $this->getEnvironment()) {
                $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            }

            if (('dev' === $this->getEnvironment()) && class_exists('\\Symfony\\Bundle\\WebServerBundle\\WebServerBundle')) {
                $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
            }
        }

        return $bundles;
    }
871129
public static function metaForTemplateEntity(
        ClassMetadataBuilder $builder
    ): void {
        $inverseOneToOne = $builder->createOneToOne(
            TemplateEntity::getDoctrineStaticMeta()->getSingular(),
            TemplateEntity::class
        );
        $inverseOneToOne
            ->mappedBy(self::getDoctrineStaticMeta()->getSingular())
            ->addJoinColumn(
                Inflector::tableize(
                    TemplateEntity::getDoctrineStaticMeta()->getSingular()
                ) . '_' . IdFieldInterface::PROP_ID,
                IdFieldInterface::PROP_ID,
                /**
                 * We have had to make this a nullable column due to the fact that Doctrine will execute inserts
                 * sequentially and so the related entity ID may not yet exist in the database.
                 *
                 * @see \Doctrine\ORM\Persisters\Entity\BasicEntityPersister::prepareUpdateData
                 */
                true
            )->build();
    }