当前位置: 首页>>代码示例>>PHP>>正文


PHP Configuration::getMigrationsDirectory方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Migrations\Configuration\Configuration::getMigrationsDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP Configuration::getMigrationsDirectory方法的具体用法?PHP Configuration::getMigrationsDirectory怎么用?PHP Configuration::getMigrationsDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Migrations\Configuration\Configuration的用法示例。


在下文中一共展示了Configuration::getMigrationsDirectory方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMigrationsInfos

 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;
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:7,代码来源:MigrationStatusInfosHelper.php

示例2: registerMigrations

 public function registerMigrations(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     if (!$this->isMigrationCommand($command)) {
         return;
     }
     $this->configuration->registerMigrationsFromDirectory($this->configuration->getMigrationsDirectory());
 }
开发者ID:DIPcom,项目名称:Sandmin,代码行数:8,代码来源:RegisterMigrationsEventSubscriber.php

示例3: 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());
 }
开发者ID:dextervip,项目名称:DoctrineMigrationsBundle,代码行数:53,代码来源:DoctrineCommand.php

示例4: getMigrationDirectory

 public function getMigrationDirectory()
 {
     $dir = $this->configuration->getMigrationsDirectory();
     $dir = $dir ? $dir : getcwd();
     $dir = rtrim($dir, '/');
     if (!file_exists($dir)) {
         throw new \InvalidArgumentException(sprintf('Migrations directory "%s" does not exist.', $dir));
     }
     if ($this->configuration->areMigrationsOrganizedByYear()) {
         $dir .= $this->appendDir(date('Y'));
     }
     if ($this->configuration->areMigrationsOrganizedByYearAndMonth()) {
         $dir .= $this->appendDir(date('m'));
     }
     $this->createDirIfNotExists($dir);
     return $dir;
 }
开发者ID:doctrine,项目名称:migrations,代码行数:17,代码来源:MigrationDirectoryHelper.php

示例5: 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;
 }
开发者ID:itkg-jfranclin,项目名称:migrations,代码行数:22,代码来源:MigrationStatusInfosHelper.php

示例6: 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());
     }
     self::injectContainerToMigrations($container, $configuration->getMigrations());
 }
开发者ID:Dren-x,项目名称:mobitnew,代码行数:38,代码来源:DoctrineCommand.php

示例7: _generateMigration

 protected function _generateMigration(Configuration $configuration, InputInterface $input, $version, $up = null, $down = null)
 {
     $placeHolders = array('<namespace>', '<version>', '<up>', '<down>');
     $replacements = array($configuration->getMigrationsNamespace(), $version, $up ? "        " . implode("\n        ", explode("\n", $up)) : null, $down ? "        " . implode("\n        ", explode("\n", $down)) : null);
     $code = str_replace($placeHolders, $replacements, self::$_template);
     $dir = $configuration->getMigrationsDirectory();
     $dir = $dir ? $dir : getcwd();
     $dir = rtrim($dir, '/');
     $path = $dir . '/Version' . $version . '.php';
     file_put_contents($path, $code);
     if ($editorCmd = $input->getOption('editor-cmd')) {
         shell_exec($editorCmd . ' ' . escapeshellarg($path));
     }
     return $path;
 }
开发者ID:poulikov,项目名称:readlater,代码行数:15,代码来源:GenerateCommand.php

示例8: register

 public function register(Application $app)
 {
     if (!isset($app['migration.outputwriter'])) {
         $app['migration.outputwriter'] = null;
     }
     $app['migration'] = $app->share(function () use($app) {
         return new Migration($app['migration.configuration']);
     });
     $app['migration.configuration'] = $app->share(function () use($app) {
         $configuration = new Configuration($app['db'], $app['migration.outputwriter']);
         if (isset($app['migration.table'])) {
             $configuration->setMigrationsTableName($app['migration.table']);
         }
         $configuration->setMigrationsNamespace($app['migration.namespace']);
         $configuration->setMigrationsDirectory($app['migration.directory']);
         $configuration->registerMigrationsFromDirectory($configuration->getMigrationsDirectory());
         return $configuration;
     });
 }
开发者ID:mac2000,项目名称:silex_migrations_service_provider,代码行数:19,代码来源:MigrationsServiceProvider.php

示例9: generateMigration

 protected function generateMigration(Configuration $configuration, InputInterface $input, $version, $up = null, $down = null)
 {
     $placeHolders = ['<namespace>', '<version>', '<up>', '<down>'];
     $replacements = [$configuration->getMigrationsNamespace(), $version, $up ? '        ' . implode("\n        ", explode("\n", $up)) : null, $down ? '        ' . implode("\n        ", explode("\n", $down)) : null];
     $code = str_replace($placeHolders, $replacements, $this->template);
     $dir = $configuration->getMigrationsDirectory();
     $dir = $dir ? $dir : getcwd();
     $dir = rtrim($dir, '/');
     $path = $dir . '/Version' . $version . '.php';
     if (!file_exists($dir)) {
         // @codeCoverageIgnoreStart
         throw new \InvalidArgumentException(sprintf('Migrations directory "%s" does not exist.', $dir));
         // @codeCoverageIgnoreEnd
     }
     file_put_contents($path, $code);
     if ($editorCmd = $input->getOption('editor-cmd')) {
         shell_exec($editorCmd . ' ' . escapeshellarg($path));
     }
     return $path;
 }
开发者ID:xrowgmbh,项目名称:ezpublish-migrations-bundle,代码行数:20,代码来源:GenerateCommand.php

示例10: writeMigrationClassToFile

    /**
     * @param \Doctrine\DBAL\Migrations\Configuration\Configuration $configuration
     * @param string $up
     * @param string $down
     * @return string
     * @throws \RuntimeException
     */
    protected function writeMigrationClassToFile(\Doctrine\DBAL\Migrations\Configuration\Configuration $configuration, $up, $down)
    {
        $namespace = $configuration->getMigrationsNamespace();
        $className = 'Version' . date('YmdHis');
        $up = $up === null ? '' : "\n\t\t" . implode("\n\t\t", explode("\n", $up));
        $down = $down === null ? '' : "\n\t\t" . implode("\n\t\t", explode("\n", $down));
        $path = \TYPO3\Flow\Utility\Files::concatenatePaths(array($configuration->getMigrationsDirectory(), $className . '.php'));
        try {
            \TYPO3\Flow\Utility\Files::createDirectoryRecursively(dirname($path));
        } catch (\TYPO3\Flow\Utility\Exception $exception) {
            throw new \RuntimeException(sprintf('Migration target directory "%s" does not exist.', dirname($path)), 1303298536, $exception);
        }
        $code = <<<EOT
<?php
namespace {$namespace};

use Doctrine\\DBAL\\Migrations\\AbstractMigration,
\tDoctrine\\DBAL\\Schema\\Schema;

/**
 * Auto-generated Migration: Please modify to your need!
 */
class {$className} extends AbstractMigration {

\t/**
\t * @param Schema \$schema
\t * @return void
\t */
\tpublic function up(Schema \$schema) {
\t\t// this up() migration is autogenerated, please modify it to your needs{$up}
\t}

\t/**
\t * @param Schema \$schema
\t * @return void
\t */
\tpublic function down(Schema \$schema) {
\t\t// this down() migration is autogenerated, please modify it to your needs{$down}
\t}
}
EOT;
        file_put_contents($path, $code);
        return $path;
    }
开发者ID:patrickreck,项目名称:flow-development-collection,代码行数:51,代码来源:Service.php

示例11: writeMigrationClassToFile

    /**
     * @param Configuration $configuration
     * @param string $up
     * @param string $down
     * @return string
     * @throws \RuntimeException
     */
    protected function writeMigrationClassToFile(Configuration $configuration, $up, $down)
    {
        $namespace = $configuration->getMigrationsNamespace();
        $className = 'Version' . date('YmdHis');
        $up = $up === null ? '' : "\n        " . implode("\n        ", explode("\n", $up));
        $down = $down === null ? '' : "\n        " . implode("\n        ", explode("\n", $down));
        $path = Files::concatenatePaths(array($configuration->getMigrationsDirectory(), $className . '.php'));
        try {
            Files::createDirectoryRecursively(dirname($path));
        } catch (Exception $exception) {
            throw new \RuntimeException(sprintf('Migration target directory "%s" does not exist.', dirname($path)), 1303298536, $exception);
        }
        $code = <<<EOT
<?php
namespace {$namespace};

use Doctrine\\DBAL\\Migrations\\AbstractMigration;
use Doctrine\\DBAL\\Schema\\Schema;

/**
 * Auto-generated Migration: Please modify to your needs! This block will be used as the migration description if getDescription() is not used.
 */
class {$className} extends AbstractMigration
{

    /**
     * @return string
     */
    public function getDescription() {
        return '';
    }

    /**
     * @param Schema \$schema
     * @return void
     */
    public function up(Schema \$schema)
    {
        // this up() migration is autogenerated, please modify it to your needs{$up}
    }

    /**
     * @param Schema \$schema
     * @return void
     */
    public function down(Schema \$schema)
    {
        // this down() migration is autogenerated, please modify it to your needs{$down}
    }
}
EOT;
        file_put_contents($path, $code);
        return $path;
    }
开发者ID:fcool,项目名称:flow-development-collection,代码行数:61,代码来源:Service.php

示例12: generateMigration

 protected function generateMigration(Configuration $configuration, InputInterface $input, $version, $up = null, $down = null)
 {
     $placeHolders = ['<namespace>', '<version>', '<up>', '<down>'];
     $replacements = [$configuration->getMigrationsNamespace(), $version, $up ? "        " . implode("\n        ", explode("\n", $up)) : null, $down ? "        " . implode("\n        ", explode("\n", $down)) : null];
     $code = str_replace($placeHolders, $replacements, self::$_template);
     $code = preg_replace('/^ +$/m', '', $code);
     $dir = $configuration->getMigrationsDirectory();
     $dir = $dir ? $dir : getcwd();
     $dir = rtrim($dir, '/');
     $path = $dir . '/Version' . $version . '.php';
     if (!file_exists($dir)) {
         throw new \InvalidArgumentException(sprintf('Migrations directory "%s" does not exist.', $dir));
     }
     file_put_contents($path, $code);
     if ($editorCmd = $input->getOption('editor-cmd')) {
         proc_open($editorCmd . ' ' . escapeshellarg($path), [], $pipes);
     }
     return $path;
 }
开发者ID:BiffBangPow,项目名称:migrations,代码行数:19,代码来源:GenerateCommand.php

示例13: getMigrationFileByVersion

 /**
  * @param string $version
  * @return string
  */
 private function getMigrationFileByVersion($version)
 {
     return $this->configuration->getMigrationsDirectory() . '/Version' . $version . '.php';
 }
开发者ID:DIPcom,项目名称:Sandmin,代码行数:8,代码来源:ChangeCodingStandardEventSubscriber.php

示例14: getMigrationConfig

 /**
  * @return Configuration
  */
 private function getMigrationConfig(array &$errors)
 {
     $connection = $this->container->get('doctrine.dbal.default_connection');
     $config = new Configuration($connection, new OutputWriter(function ($message) use($errors) {
         $matches = [];
         if (preg_match('#<error>(.*)</error>#', $message, $matches)) {
             $errors += $matches;
         }
     }));
     $config->setName($this->container->getParameter('doctrine_migrations.name'));
     $config->setMigrationsTableName($this->container->getParameter('doctrine_migrations.table_name'));
     $config->setMigrationsNamespace($this->container->getParameter('doctrine_migrations.namespace'));
     $config->setMigrationsDirectory($this->container->getParameter('doctrine_migrations.dir_name'));
     // Register Migrations as there are not registered by Configuration
     $config->registerMigrationsFromDirectory($config->getMigrationsDirectory());
     return $config;
 }
开发者ID:Onneil,项目名称:dedipanel,代码行数:20,代码来源:AutoInstallStep.php


注:本文中的Doctrine\DBAL\Migrations\Configuration\Configuration::getMigrationsDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。