protected function processMigration(&$index, array $migrations, Migration $migration)
    {
        if (in_array($migration->getStatus(), [Migration::STATUS_MIGRATED, Migration::STATUS_RECURSIVE_FOREIGN_KEY], true)) {
            return;
        }
        $migration->setStatus(Migration::STATUS_IN_PROGRESS);

        // Check foreign keys
        $tableNames = $migration->getTable()->getForeignTableNames();
        foreach ($tableNames as $tableName) {
            if ($migration->getTable()->getTableName() === $tableName) {
                continue;
            }

            // Check recursive foreign key
            if (isset($migrations[$tableName]) && $migrations[$tableName]->getStatus() === Migration::STATUS_IN_PROGRESS) {
                $migration->setStatus(Migration::STATUS_RECURSIVE_FOREIGN_KEY);
                continue;
            }

            $this->processMigration($index, $migrations, $migrations[$tableName]);
        }

        $migration->writeTableOut($index, $this->output, $this->option('force'));

        if ($migration->getStatus() !== Migration::STATUS_RECURSIVE_FOREIGN_KEY) {
            $migration->setStatus(Migration::STATUS_MIGRATED);
        }

        $index++;
    }
protected function processMigration(&$index, array $migrations, Migration $migration)
    {
        if (in_array($migration->getStatus(), [Migration::STATUS_MIGRATED, Migration::STATUS_RECURSIVE_FOREIGN_KEY], true)) {
            return;
        }
        $migration->setStatus(Migration::STATUS_IN_PROGRESS);

        // Check foreign keys
        $tableNames = $migration->getTable()->getForeignTableNames();
        foreach ($tableNames as $tableName) {
            if ($migration->getTable()->getTableName() === $tableName) {
                continue;
            }

            // Check recursive foreign key
            if (isset($migrations[$tableName]) && $migrations[$tableName]->getStatus() === Migration::STATUS_IN_PROGRESS) {
                $migration->setStatus(Migration::STATUS_RECURSIVE_FOREIGN_KEY);
                continue;
            }

            $this->processMigration($index, $migrations, $migrations[$tableName]);
        }

        $migration->writeTableOut($index, $this->output, $this->option('force'));

        if ($migration->getStatus() !== Migration::STATUS_RECURSIVE_FOREIGN_KEY) {
            $migration->setStatus(Migration::STATUS_MIGRATED);
        }

        $index++;
    }
protected function processMigration ( & $ index , array $ migrations , Migration $ migration ) { if ( in_array ( $ migration -> getStatus ( ) , [ Migration :: STATUS_MIGRATED , Migration :: STATUS_RECURSIVE_FOREIGN_KEY ] , true ) ) { return ; } $ migration -> setStatus ( Migration :: STATUS_IN_PROGRESS ) ; // Check foreign keys $ tableNames = $ migration -> getTable ( ) -> getForeignTableNames ( ) ; foreach ( $ tableNames as $ tableName ) { if ( $ migration -> getTable ( ) -> getTableName ( ) === $ tableName ) { continue ; } // Check recursive foreign key if ( isset ( $ migrations [ $ tableName ] ) && $ migrations [ $ tableName ] -> getStatus ( ) === Migration :: STATUS_IN_PROGRESS ) { $ migration -> setStatus ( Migration :: STATUS_RECURSIVE_FOREIGN_KEY ) ; continue ; } $ this -> processMigration ( $ index , $ migrations , $ migrations [ $ tableName ] ) ; } $ migration -> writeTableOut ( $ index , $ this -> output , $ this -> option ( 'force' ) ) ; if ( $ migration -> getStatus ( ) !== Migration :: STATUS_RECURSIVE_FOREIGN_KEY ) { $ migration -> setStatus ( Migration :: STATUS_MIGRATED ) ; } $ index ++ ; }
Export table to file

@param int                                $index      file index
@param \ViKon\DbExporter\Meta\Migration[] $migrations available tables instances
@param \ViKon\DbExporter\Meta\Migration   $migration  actual table instance files
Export table to file