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([$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;
}