protected function sortTablesWithFKsToEnd(array $tables)
    {
        $return = [];

        while ($tables) {
            /** @var TableMigration $table */
            foreach ($tables as $key => $table) {
                // if there are no fks or the required fks are allready saved.
                if ((!$fks = $table->getForeignKeys()) || (count(array_intersect_key($return, $fks)) === count($fks))) {
                    $return[$table->getName()] = $table;
                    unset($tables[$key]);
                } // if
            } // foreach
        } // while

        return $return;
    }
protected function sortTablesWithFKsToEnd(array $tables)
    {
        $return = [];

        while ($tables) {
            /** @var TableMigration $table */
            foreach ($tables as $key => $table) {
                // if there are no fks or the required fks are allready saved.
                if ((!$fks = $table->getForeignKeys()) || (count(array_intersect_key($return, $fks)) === count($fks))) {
                    $return[$table->getName()] = $table;
                    unset($tables[$key]);
                } // if
            } // foreach
        } // while

        return $return;
    }
protected function sortTablesWithFKsToEnd ( array $ tables ) { $ return = [ ] ; while ( $ tables ) { /** @var TableMigration $table */ foreach ( $ tables as $ key => $ table ) { // if there are no fks or the required fks are allready saved. if ( ( ! $ fks = $ table -> getForeignKeys ( ) ) || ( count ( array_intersect_key ( $ return , $ fks ) ) === count ( $ fks ) ) ) { $ return [ $ table -> getName ( ) ] = $ table ; unset ( $ tables [ $ key ] ) ; } // if } // foreach } // while return $ return ; }
Callback to sort tables with foreign keys to the end.
@param TableMigration[] $tables
@return TableMigration[]
Callback to sort tables with foreign keys to the end .