concrete/src/Updater/Migrations/Configuration.php
protected function findInitialMigrationByCoreVersion($coreVersion, $criteria)
    {
        $coreVersionNormalized = preg_replace('/(\.0+)+$/', '', $coreVersion);
        if (version_compare($coreVersionNormalized, '5.7') < 0) {
            throw new Exception(t('Invalid version specified (%s).', $coreVersion));
        }
        $migrations = $this->getMigrations();
        $migrationIdentifiers = array_keys($migrations);
        $maxMigrationIndex = count($migrationIdentifiers) - 1;
        $result = null;
        foreach ($migrations as $identifier => $migration) {
            $migrationCoreVersionNormalized = preg_replace('/(\.0+)+$/', '', $migration->getMigration()->getDescription());
            if ($migrationCoreVersionNormalized !== '') {
                $cmp = version_compare($migrationCoreVersionNormalized, $coreVersionNormalized);
                if ($cmp <= 0 || $result === null) {
                    switch ($criteria) {
                        case static::FORCEDMIGRATION_INCLUSIVE:
                            $result = $migration;
                            break;
                        case static::FORCEDMIGRATION_EXCLUSIVE:
                            $migrationIndex = array_search($identifier, $migrationIdentifiers, false);
                            $result = $migrationIndex === $maxMigrationIndex ? null : $migrations[$migrationIdentifiers[$migrationIndex + 1]];
                            break;
                        default:
                            throw new Exception(t('Invalid initial migration criteria.'));
                    }
                }
                if ($cmp >= 0) {
                    break;
                }
            }
        }

        return $result;
    }
protected function findInitialMigrationByCoreVersion($coreVersion, $criteria)
    {
        $coreVersionNormalized = preg_replace('/(\.0+)+$/', '', $coreVersion);
        if (version_compare($coreVersionNormalized, '5.7') < 0) {
            throw new Exception(t('Invalid version specified (%s).', $coreVersion));
        }
        $migrations = $this->getMigrations();
        $migrationIdentifiers = array_keys($migrations);
        $maxMigrationIndex = count($migrationIdentifiers) - 1;
        $result = null;
        foreach ($migrations as $identifier => $migration) {
            $migrationCoreVersionNormalized = preg_replace('/(\.0+)+$/', '', $migration->getMigration()->getDescription());
            if ($migrationCoreVersionNormalized !== '') {
                $cmp = version_compare($migrationCoreVersionNormalized, $coreVersionNormalized);
                if ($cmp <= 0 || $result === null) {
                    switch ($criteria) {
                        case static::FORCEDMIGRATION_INCLUSIVE:
                            $result = $migration;
                            break;
                        case static::FORCEDMIGRATION_EXCLUSIVE:
                            $migrationIndex = array_search($identifier, $migrationIdentifiers, false);
                            $result = $migrationIndex === $maxMigrationIndex ? null : $migrations[$migrationIdentifiers[$migrationIndex + 1]];
                            break;
                        default:
                            throw new Exception(t('Invalid initial migration criteria.'));
                    }
                }
                if ($cmp >= 0) {
                    break;
                }
            }
        }

        return $result;
    }
protected function findInitialMigrationByCoreVersion ( $ coreVersion , $ criteria ) { $ coreVersionNormalized = preg_replace ( '/(\.0+)+$/' , '' , $ coreVersion ) ; if ( version_compare ( $ coreVersionNormalized , '5.7' ) < 0 ) { throw new Exception ( t ( 'Invalid version specified (%s).' , $ coreVersion ) ) ; } $ migrations = $ this -> getMigrations ( ) ; $ migrationIdentifiers = array_keys ( $ migrations ) ; $ maxMigrationIndex = count ( $ migrationIdentifiers ) - 1 ; $ result = null ; foreach ( $ migrations as $ identifier => $ migration ) { $ migrationCoreVersionNormalized = preg_replace ( '/(\.0+)+$/' , '' , $ migration -> getMigration ( ) -> getDescription ( ) ) ; if ( $ migrationCoreVersionNormalized !== '' ) { $ cmp = version_compare ( $ migrationCoreVersionNormalized , $ coreVersionNormalized ) ; if ( $ cmp <= 0 || $ result === null ) { switch ( $ criteria ) { case static :: FORCEDMIGRATION_INCLUSIVE : $ result = $ migration ; break ; case static :: FORCEDMIGRATION_EXCLUSIVE : $ migrationIndex = array_search ( $ identifier , $ migrationIdentifiers , false ) ; $ result = $ migrationIndex === $ maxMigrationIndex ? null : $ migrations [ $ migrationIdentifiers [ $ migrationIndex + 1 ] ] ; break ; default : throw new Exception ( t ( 'Invalid initial migration criteria.' ) ) ; } } if ( $ cmp >= 0 ) { break ; } } } return $ result ; }
Get the initial migration starting from a core version.

@param string $coreVersion The core version
@param string $criteria One of the FORCEDMIGRATION_... constants

@throws Exception throws an Exception if $criteria is not valid

@return \Doctrine\DBAL\Migrations\Version|null

@example If looking for version 1.4:

20010101000000 v1.1
20020101000000
20030101000000
20040101000000 v1.3  <- if $criteria is FORCEDMIGRATION_INCLUSIVE
20050101000000       <- if $criteria is FORCEDMIGRATION_EXCLUSIVE
20060101000000
20070101000000 v1.5
Get the initial migration starting from a core version .