MigrationVersion::_enumerateNewMigrations PHP Method

_enumerateNewMigrations() protected method

Returns a map of all available migrations for a type (app or plugin) using inflection
protected _enumerateNewMigrations ( 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 _enumerateNewMigrations($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) {
                $mapping[(int) $version] = array(substr($file, 0, -4) => Inflector::camelize(substr($className, 0, -4)));
            }
        }
        return $mapping;
    }