From 67e668dcd5e46b459960ff1daa35663d25bf1c8e Mon Sep 17 00:00:00 2001 From: Luca Saba Date: Tue, 16 Apr 2013 11:02:37 +0200 Subject: [PATCH] Creates the fixturs folder if needed With this change, if the fixtures folder does not exists the propel:fixtures:dump command asks user's confirmation for its creation. If the user deny the authorization, the command will throw a IOException (before file_put_contents rises a warning). --- Command/FixturesDumpCommand.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Command/FixturesDumpCommand.php b/Command/FixturesDumpCommand.php index abaa037..360677e 100644 --- a/Command/FixturesDumpCommand.php +++ b/Command/FixturesDumpCommand.php @@ -62,7 +62,18 @@ EOT list($name, $defaultConfig) = $this->getConnection($input, $output); $fixtureDir = $input->getOption('dir') ? $input->getOption('dir') : $this->defaultFixturesDir; - $path = realpath($this->getApplication()->getKernel()->getRootDir() . '/../') . '/' . $fixtureDir; + $path = realpath($this->getApplication()->getKernel()->getRootDir() . '/../') . '/' . $fixtureDir; + + if (!file_exists($path)) { + $output->writeln("The $path folder does not exists."); + if ($this->askConfirmation($output, "Do you want me to create it for you ? [Yes]")) { + $fs = new Filesystem(); + $fs->mkdir($path); + } else { + throw new \IOException(sprintf('Unable to find the %s folder', $path)); + } + } + $filename = $path . '/fixtures_' . time() . '.yml'; $dumper = new YamlDataDumper($this->getApplication()->getKernel()->getRootDir());