MigrationVersion::_enumerateOldMigrations PHP Method

_enumerateOldMigrations() protected method

Returns a map of all available migrations for a type (app or plugin) using regular expressions
protected _enumerateOldMigrations ( string $type ) : array
$type string Can be 'app' or a plugin name
return array containing a list of migration versions ordered by filename
    protected function _enumerateOldMigrations($type)
    {
        $mapping = array();
        $path = APP . 'Config' . DS . 'Migration' . DS;
        if ($type !== 'app') {
            $path = CakePlugin::path(Inflector::camelize($type)) . 'Config' . DS . 'Migration' . DS;
        }
        if (!file_exists($path)) {
            return $mapping;
        }
        $folder = new Folder($path);
        foreach ($folder->find('.*?\\.php', true) as $file) {
            $parts = explode('_', $file);
            $version = array_shift($parts);
            $className = implode('_', $parts);
            if ($version > 0 && strlen($className) > 0) {
                $contents = file_get_contents($path . $file);
                if (preg_match("/class\\s([\\w]+)\\sextends/", $contents, $matches)) {
                    $mapping[(int) $version] = array(substr($file, 0, -4) => $matches[1]);
                }
            }
        }
        return $mapping;
    }