protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $arguments = $input->getArguments(); $migrationName = $arguments['migration_name']; $filenameBuilder = new FileNameBuilder($migrationName); $fileSystem = new Filesystem(); $templateRenderer = $this->getContainer()->get('dami.template_renderer'); $migrationDirectory = $this->getContainer()->getparameter('dami.migrations_directory'); try { $fileName = $filenameBuilder->build(); $path = $migrationDirectory . '/' . $fileName; $fileSystem->dumpFile($path, $templateRenderer->render($migrationName)); $output->writeln('<info>Migration has been created.</info>'); $output->writeln(sprintf('<comment>Location: %s</comment>', $path)); } catch (\Exception $e) { $output->writeln(sprintf("<error>Something went wrong.</error>\n\n%s", $e->getMessage())); } }
public function testBuild() { $fileNameBuilder = new FileNameBuilder('AddTableFoo'); $dateTime = new \DateTime("2013-01-01 00:00:00"); $this->assertEquals('20130101000000_add_table_foo.php', $fileNameBuilder->build($dateTime->format('YmdHis'))); }