本文整理汇总了PHP中Migration::setVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::setVersion方法的具体用法?PHP Migration::setVersion怎么用?PHP Migration::setVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::setVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Migration
$rootPath = $modx->getOption('cronmanager.core_path', null, $modx->getOption('core_path') . 'components/cronmanager/');
$modelPath = $rootPath . 'model/';
$loaded = $modx->loadClass('Migration', $modelPath . 'migration/', true, true);
$migration = new Migration($modx, array('component_name' => PKG_NAME_LOWER, 'package_name' => PKG_NAME_LOWER, 'namespace' => $options['namespace'], 'migrations_path' => $rootPath . 'migrations/'));
// Get signature
$tmpVersion = $migration->getVersion($options);
$name = $options['namespace'];
$thisVersion = str_replace($name . '-', '', $tmpVersion);
switch ($options[xPDOTransport::PACKAGE_ACTION]) {
case xPDOTransport::ACTION_INSTALL:
$modx->log(modX::LOG_LEVEL_INFO, 'Installing version : ' . $thisVersion);
$modx->addPackage('cronmanager', $modelPath);
$manager = $modx->getManager();
$manager->createObjectContainer('modCronjob');
$manager->createObjectContainer('modCronjobLog');
break;
case xPDOTransport::ACTION_UPGRADE:
$modx->addPackage('cronmanager', $modelPath);
// Get previously installed version
$previousVersion = $migration->getPreviousVersion();
$modx->log(modX::LOG_LEVEL_INFO, 'Previous version : ' . $previousVersion);
// Lets trigger appropriate "migrations"
$for = '1.1.5-beta';
if (version_compare($previousVersion, $for) <= 0) {
include_once $migration->getMigration($for);
}
break;
}
// Update the version setting
$migration->setVersion($thisVersion);
}