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).
This commit is contained in:
Luca Saba 2013-04-16 11:02:37 +02:00
commit 67e668dcd5

View file

@ -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("<info>The $path folder does not exists.</info>");
if ($this->askConfirmation($output, "<question>Do you want me to create it for you ?</question> [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());