Doctrine\DBAL\Migrations\Configuration\Configuration::resolveVersionAlias PHP Method

resolveVersionAlias() public method

Supported aliases are: - first: The very first version before any migrations have been run. - current: The current version. - prev: The version prior to the current version. - next: The version following the current version. - latest: The latest available version. If an existing version number is specified, it is returned verbatimly.
public resolveVersionAlias ( $alias ) : string | null
return string | null A version number, or null if the specified alias does not map to an existing version, e.g. if "next" is passed but the current version is already the latest.
    public function resolveVersionAlias($alias)
    {
        if ($this->hasVersion($alias)) {
            return $alias;
        }
        switch ($alias) {
            case 'first':
                return '0';
            case 'current':
                return $this->getCurrentVersion();
            case 'prev':
                return $this->getPrevVersion();
            case 'next':
                return $this->getNextVersion();
            case 'latest':
                return $this->getLatestVersion();
            default:
                return null;
        }
    }

Usage Example

 private function getFormattedVersionAlias($alias)
 {
     $version = $this->configuration->resolveVersionAlias($alias);
     //No version found
     if ($version === null) {
         if ($alias == 'next') {
             return 'Already at latest version';
         } elseif ($alias == 'prev') {
             return 'Already at first version';
         }
     }
     //Before first version "virtual" version number
     if ($version === '0') {
         return '<comment>0</comment>';
     }
     //Show normal version number
     return $this->configuration->getDateTime($version) . ' (<comment>' . $version . '</comment>)';
 }
All Usage Examples Of Doctrine\DBAL\Migrations\Configuration\Configuration::resolveVersionAlias