RainLab\Builder\Classes\MigrationModel::getNextVersion PHP 메소드

getNextVersion() 공개 메소드

public getNextVersion ( )
    public function getNextVersion()
    {
        $versionInformation = $this->getPluginVersionInformation();
        if (!count($versionInformation)) {
            return '1.0.0';
        }
        $versions = array_keys($versionInformation);
        $latestVersion = end($versions);
        $versionNumbers = [];
        if (!preg_match('/^([0-9]+)\\.([0-9]+)\\.([0-9]+)$/', $latestVersion, $versionNumbers)) {
            throw new SystemException(sprintf('Cannot parse the latest plugin version number: %s.', $latestVersion));
        }
        return $versionNumbers[1] . '.' . $versionNumbers[2] . '.' . ($versionNumbers[3] + 1);
    }

Usage Example

 protected function createMigrationObject($code, $description)
 {
     $migration = new MigrationModel();
     $migration->setPluginCodeObj($this->getPluginCodeObj());
     $migration->code = $code;
     $migration->version = $migration->getNextVersion();
     $migration->description = $description;
     return $migration;
 }