Example #1
0
 protected function _generateMigration(Configuration $configuration, InputInterface $input, $version, $up = null, $down = null)
 {
     $placeHolders = array('<version>', '<up>', '<down>');
     $replacements = array($version, $up ? "        " . implode("\n        ", explode("\n", $up)) : null, $down ? "        " . implode("\n        ", explode("\n", $down)) : null);
     $code = str_replace($placeHolders, $replacements, self::$_template);
     $dir = $configuration->getNewMigrationsDirectory();
     $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;
 }