getMigration() public method

public getMigration ( ) : Doctrine\DBAL\Migrations\AbstractMigration
return Doctrine\DBAL\Migrations\AbstractMigration
Ejemplo n.º 1
0
 /**
  * Create migration with description
  */
 public function testCreateVersionWithCustomName()
 {
     $versionName = '003';
     $versionDescription = 'My super migration';
     $version = new Version(new Configuration($this->getSqliteConnection()), $versionName, 'Doctrine\\DBAL\\Migrations\\Tests\\Stub\\VersionDummyDescription');
     $this->assertEquals($versionName, $version->getVersion());
     $this->assertEquals($versionDescription, $version->getMigration()->getDescription());
 }
 /**
  * Tries to find out a package key which the Version belongs to. If no
  * package could be found, an empty string is returned.
  *
  * @param Version $version
  * @return string
  */
 protected function getPackageKeyFromMigrationVersion(Version $version)
 {
     $sortedAvailablePackages = $this->packageManager->getAvailablePackages();
     usort($sortedAvailablePackages, function (PackageInterface $packageOne, PackageInterface $packageTwo) {
         return strlen($packageTwo->getPackagePath()) - strlen($packageOne->getPackagePath());
     });
     $reflectedClass = new \ReflectionClass($version->getMigration());
     $classPathAndFilename = Files::getUnixStylePath($reflectedClass->getFileName());
     /** @var $package PackageInterface */
     foreach ($sortedAvailablePackages as $package) {
         $packagePath = Files::getUnixStylePath($package->getPackagePath());
         if (strpos($classPathAndFilename, $packagePath) === 0) {
             return $package->getPackageKey();
         }
     }
     return '';
 }
Ejemplo n.º 3
0
 /**
  * Returns the description of a migration.
  *
  * If available it is fetched from the getDescription() method, if that returns an empty value
  * the class docblock is used instead.
  *
  * @param Version $version
  * @param DocCommentParser $parser
  * @return string
  */
 protected function getMigrationDescription(Version $version, DocCommentParser $parser)
 {
     if ($version->getMigration()->getDescription()) {
         return $version->getMigration()->getDescription();
     } else {
         $reflectedClass = new \ReflectionClass($version->getMigration());
         $parser->parseDocComment($reflectedClass->getDocComment());
         return str_replace([chr(10), chr(13)], ' ', $parser->getDescription());
     }
 }