예제 #1
0
 /**
  * Formats and prints a pending version with the given style.
  *
  * @param Version $version The Version to print.
  * @param string $style One of the STYLE_* constants.
  */
 protected function printPendingVersion(Version $version, $style)
 {
     /** @var Version $version */
     $id = $version->getId();
     $reflectionClass = new \ReflectionClass($version->getMigration());
     $absolutePath = $reflectionClass->getFileName();
     $fileName = $absolutePath ? $this->getRelativePath(getcwd(), $absolutePath) : '';
     $this->output->writeln("\t<{$style}>[{$id}] {$fileName}</{$style}>");
 }
예제 #2
0
 /**
  * @param $id string
  * @param bool $migrated
  * @param MigrationInterface $migration
  *
  * @throws InvalidArgumentException
  */
 public function __construct($id, $migrated, MigrationInterface $migration)
 {
     $this->migration = $migration;
     parent::__construct($id, $migrated);
 }
 /**
  * findMigrationByVersion
  *
  * @param Version $version
  *
  * @return false|Migration
  */
 protected function findMigrationByVersion(Version $version)
 {
     return Migration::getById($version->getId());
 }
예제 #4
0
 /**
  * Reads versions from the storage file.
  *
  * @return VersionInterface[]
  *
  * @throws StorageException
  */
 protected function doFetchAll()
 {
     $contents = $this->file->read();
     $lines = explode("\n", $contents);
     $collection = new Migrated();
     foreach ($lines as $line) {
         $line = trim($line);
         if (!empty($line)) {
             // skip empty lines
             $version = new Version($line);
             $version->setMigrated(true);
             // if its in storage its because it has been migrated
             $collection->add($version);
         }
     }
     return $collection;
 }