Example #1
0
 /**
  * Factory method that runs a given migration.
  *
  * @param string $fileName
  * @param string $direction
  */
 public static function run($fileName, $direction, $verbose)
 {
     if ($direction == 'drop') {
         // We create a fake instance here since drop is not associated
         // with any real migration class.
         $dropper = new self('', __CLASS__);
         $dropper->migrate('drop');
         return;
     }
     $inflector = new Zend_Filter_Inflector(':class', array(':class' => 'Word_DashToCamelCase'));
     preg_match('/(\\d+)_(.+)\\.php/', basename($fileName), $matches);
     $version = $matches[1];
     $class = $inflector->filter(array(':class' => $matches[2]));
     include $fileName;
     if (class_exists($class)) {
         $migration = new $class($version, $class, $verbose);
         $migration->migrate($direction);
         $migration->updateInstalledVersions($version, $direction);
     } else {
         $msg = "Class '{$class}' is not present in the migration file";
         $this->write($msg);
         throw new Svenax_Migration_Exception($msg);
     }
 }
 public static function fire(SetupCommand $setupCommand)
 {
     $run = new self();
     $run->migrate($setupCommand);
 }