本文整理汇总了PHP中Doctrine\DBAL\Migrations\Configuration\Configuration::setMigrationsAreOrganizedByYear方法的典型用法代码示例。如果您正苦于以下问题:PHP Configuration::setMigrationsAreOrganizedByYear方法的具体用法?PHP Configuration::setMigrationsAreOrganizedByYear怎么用?PHP Configuration::setMigrationsAreOrganizedByYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Migrations\Configuration\Configuration
的用法示例。
在下文中一共展示了Configuration::setMigrationsAreOrganizedByYear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configureMigrations
public static function configureMigrations(ContainerInterface $container, Configuration $configuration)
{
if (!$configuration->getMigrationsDirectory()) {
$dir = $container->getParameter('doctrine_migrations.dir_name');
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
$configuration->setMigrationsDirectory($dir);
} else {
$dir = $configuration->getMigrationsDirectory();
// class Kernel has method getKernelParameters with some of the important path parameters
$pathPlaceholderArray = array('kernel.root_dir', 'kernel.cache_dir', 'kernel.logs_dir');
foreach ($pathPlaceholderArray as $pathPlaceholder) {
if ($container->hasParameter($pathPlaceholder) && preg_match('/\\%' . $pathPlaceholder . '\\%/', $dir)) {
$dir = str_replace('%' . $pathPlaceholder . '%', $container->getParameter($pathPlaceholder), $dir);
}
}
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
$configuration->setMigrationsDirectory($dir);
}
if (!$configuration->getMigrationsNamespace()) {
$configuration->setMigrationsNamespace($container->getParameter('doctrine_migrations.namespace'));
}
if (!$configuration->getName()) {
$configuration->setName($container->getParameter('doctrine_migrations.name'));
}
// For backward compatibility, need use a table from parameters for overwrite the default configuration
if (!$configuration->getMigrationsTableName() || !$configuration instanceof AbstractFileConfiguration) {
$configuration->setMigrationsTableName($container->getParameter('doctrine_migrations.table_name'));
}
// Migrations is not register from configuration loader
if (!$configuration instanceof AbstractFileConfiguration) {
$configuration->registerMigrationsFromDirectory($configuration->getMigrationsDirectory());
}
if ($container->hasParameter('doctrine_migrations.organize_migrations')) {
$organizeMigrations = $container->getParameter('doctrine_migrations.organize_migrations');
switch ($organizeMigrations) {
case Configuration::VERSIONS_ORGANIZATION_BY_YEAR:
$configuration->setMigrationsAreOrganizedByYear(true);
break;
case Configuration::VERSIONS_ORGANIZATION_BY_YEAR_AND_MONTH:
$configuration->setMigrationsAreOrganizedByYearAndMonth(true);
break;
case false:
break;
default:
throw new InvalidConfigurationException('Unrecognized option "' . $organizeMigrations . '" under "organize_migrations"');
}
}
self::injectContainerToMigrations($container, $configuration->getMigrations());
}