getName() публичный Метод

Returns the name of this set of migrations
public getName ( ) : string
Результат string $name The name of this set of migrations
 public function getMigrationsInfos()
 {
     $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' => $this->getFormattedVersionAlias('prev'), 'Current Version' => $this->getFormattedVersionAlias('current'), 'Next Version' => $this->getFormattedVersionAlias('next'), 'Latest Version' => $this->getFormattedVersionAlias('latest'), 'Executed Migrations' => count($this->executedMigrations), 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations, 'Available Migrations' => count($this->availableMigrations), 'New Migrations' => $numNewMigrations];
     return $infos;
 }
Пример #2
0
 protected function outputHeader(Configuration $configuration, OutputInterface $output)
 {
     $name = $configuration->getName();
     $name = $name ? $name : 'Doctrine Database Migrations';
     $name = str_repeat(' ', 20) . $name . str_repeat(' ', 20);
     $output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>');
     $output->writeln('<question>' . $name . '</question>');
     $output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>');
     $output->writeln('');
 }
 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());
 }
 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;
 }
Пример #5
0
 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());
     }
     self::injectContainerToMigrations($container, $configuration->getMigrations());
 }
Пример #6
0
 public function testSetGetName()
 {
     $config = new Configuration($this->getSqliteConnection());
     $config->setName('Test');
     $this->assertEquals('Test', $config->getName());
 }