本文整理汇总了PHP中Doctrine\DBAL\Migrations\Configuration\Configuration::resolveVersionAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP Configuration::resolveVersionAlias方法的具体用法?PHP Configuration::resolveVersionAlias怎么用?PHP Configuration::resolveVersionAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Migrations\Configuration\Configuration
的用法示例。
在下文中一共展示了Configuration::resolveVersionAlias方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFormattedVersionAlias
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>)';
}
示例2: getMigrationsInfos
public function getMigrationsInfos()
{
$formattedVersions = [];
foreach (['prev', 'current', 'next', 'latest'] as $alias) {
$version = $this->configuration->resolveVersionAlias($alias);
if ($version === null) {
if ($alias == 'next') {
$formattedVersions[$alias] = 'Already at latest version';
} elseif ($alias == 'prev') {
$formattedVersions[$alias] = 'Already at first version';
}
} elseif ($version === '0') {
$formattedVersions[$alias] = '<comment>0</comment>';
} else {
$formattedVersions[$alias] = $this->configuration->getDateTime($version) . ' (<comment>' . $version . '</comment>)';
}
}
$numExecutedUnavailableMigrations = count($this->executedUnavailableMigrations);
$numNewMigrations = count(array_diff($this->availableMigrations, $this->executedMigrations));
$infos = ['Name' => $this->configuration->getName() ? $this->configuration->getName() : 'Doctrine Database Migrations', 'Database Driver' => $this->configuration->getConnection()->getDriver()->getName(), 'Database Name' => $this->configuration->getConnection()->getDatabase(), 'Configuration Source' => $this->configuration instanceof AbstractFileConfiguration ? $this->configuration->getFile() : 'manually configured', 'Version Table Name' => $this->configuration->getMigrationsTableName(), 'Version Column Name' => $this->configuration->getMigrationsColumnName(), 'Migrations Namespace' => $this->configuration->getMigrationsNamespace(), 'Migrations Directory' => $this->configuration->getMigrationsDirectory(), 'Previous Version' => $formattedVersions['prev'], 'Current Version' => $formattedVersions['current'], 'Next Version' => $formattedVersions['next'], 'Latest Version' => $formattedVersions['latest'], 'Executed Migrations' => count($this->executedMigrations), 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations, 'Available Migrations' => count($this->availableMigrations), 'New Migrations' => $numNewMigrations];
return $infos;
}
示例3: getVersionNameFromAlias
/**
* @param string $versionAlias
* @param OutputInterface $output
* @param Configuration $configuration
* @return bool|string
*/
private function getVersionNameFromAlias($versionAlias, OutputInterface $output, Configuration $configuration)
{
$version = $configuration->resolveVersionAlias($versionAlias);
if ($version === null) {
if ($versionAlias == 'prev') {
$output->writeln('<error>Already at first version.</error>');
return false;
}
if ($versionAlias == 'next') {
$output->writeln('<error>Already at latest version.</error>');
return false;
}
$output->writeln(sprintf('<error>Unknown version: %s</error>', $output->getFormatter()->escape($versionAlias)));
return false;
}
return $version;
}
示例4: getFormattedVersionAlias
/**
* Returns a formatted version string for the alias.
*
* @param string $alias
* @param Configuration $configuration
* @return string
*/
protected function getFormattedVersionAlias($alias, Configuration $configuration)
{
$version = $configuration->resolveVersionAlias($alias);
if ($version === null) {
if ($alias == 'next') {
return 'Already at latest version';
} elseif ($alias == 'prev') {
return 'Already at first version';
}
}
if ($version === '0') {
return '<comment>0</comment>';
}
return $configuration->getDateTime($version) . ' (<comment>' . $version . '</comment>)';
}