Skip to content

[Generator] [Command|Manager] fixed regression introduced in #cd22336. #296

Merged
merged 1 commit into from Aug 22, 2012
View
12 src/Propel/Generator/Command/AbstractCommand.php
@@ -13,6 +13,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Finder\Finder;
+use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
use Propel\Generator\Exception\RuntimeException;
@@ -87,6 +88,17 @@ protected function getFilesystem()
return $this->filesystem;
}
+ protected function createDirectory($directory)
+ {
+ $filesystem = $this->getFilesystem();
+
+ try {
+ $filesystem->mkdir($directory);
+ } catch (IOException $e) {
+ throw new \RuntimeException(sprintf('Unable to write the "%s" directory', $directory), 0, $e);
+ }
+ }
+
protected function parseConnection($connection)
{
$pos = strpos($connection, '=');
View
5 src/Propel/Generator/Command/ConfigConvertXmlCommand.php
@@ -49,10 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
throw new \RuntimeException(sprintf('Unable to find the "%s" configuration file', $inputFilePath));
}
- $filesystem = $this->getFilesystem();
- if (!$filesystem->mkdir($input->getOption('output-dir'))) {
- throw new \RuntimeException(sprintf('Unable to write the "%s" output directory', $input->getOption('output-dir')));
- };
+ $this->createDirectory($input->getOption('output-dir'));
$outputFilePath = $input->getOption('output-dir') . DIRECTORY_SEPARATOR .$input->getOption('output-file');
if (!is_writable(dirname($outputFilePath))) {
View
3 src/Propel/Generator/Command/DatabaseReverseCommand.php
@@ -60,8 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.reverse.parser.class' => sprintf('\\Propel\\Generator\\Reverse\\%sSchemaParser', $vendor),
));
- $filesystem = $this->getFilesystem();
- $filesystem->mkdir($input->getOption('output-dir'));
+ $this->createDirectory($input->getOption('output-dir'));
$manager = new ReverseManager();
$manager->setGeneratorConfig($generatorConfig);
View
3 src/Propel/Generator/Command/GraphvizGenerateCommand.php
@@ -48,8 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.packageObjectModel' => true,
));
- $filesystem = $this->getFilesystem();
- $filesystem->mkdir($input->getOption('output-dir'));
+ $this->createDirectory($input->getOption('output-dir'));
$manager = new GraphvizManager();
$manager->setGeneratorConfig($generatorConfig);
View
3 src/Propel/Generator/Command/MigrationDiffCommand.php
@@ -54,8 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.platform.class' => $input->getOption('platform'),
));
- $filesystem = $this->getFilesystem();
- $filesystem->mkdir($input->getOption('output-dir'));
+ $this->createDirectory($input->getOption('output-dir'));
$manager = new MigrationManager();
$manager->setGeneratorConfig($generatorConfig);
View
3 src/Propel/Generator/Command/MigrationDownCommand.php
@@ -51,8 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.platform.class' => $input->getOption('platform'),
));
- $filesystem = $this->getFilesystem();
- $filesystem->mkdir($input->getOption('output-dir'));
+ $this->createDirectory($input->getOption('output-dir'));
$manager = new MigrationManager();
$manager->setGeneratorConfig($generatorConfig);
View
3 src/Propel/Generator/Command/MigrationMigrateCommand.php
@@ -51,8 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.platform.class' => $input->getOption('platform'),
));
- $filesystem = $this->getFilesystem();
- $filesystem->mkdir($input->getOption('output-dir'));
+ $this->createDirectory($input->getOption('output-dir'));
$manager = new MigrationManager();
$manager->setGeneratorConfig($generatorConfig);
View
3 src/Propel/Generator/Command/MigrationStatusCommand.php
@@ -51,8 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.platform.class' => $input->getOption('platform'),
));
- $filesystem = $this->getFilesystem();
- $filesystem->mkdir($input->getOption('output-dir'));
+ $this->createDirectory($input->getOption('output-dir'));
$manager = new MigrationManager();
$manager->setGeneratorConfig($generatorConfig);
View
3 src/Propel/Generator/Command/MigrationUpCommand.php
@@ -51,8 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.platform.class' => $input->getOption('platform'),
));
- $filesystem = $this->getFilesystem();
- $filesystem->mkdir($input->getOption('output-dir'));
+ $this->createDirectory($input->getOption('output-dir'));
$manager = new MigrationManager();
$manager->setGeneratorConfig($generatorConfig);
View
4 src/Propel/Generator/Command/ModelBuildCommand.php
@@ -132,10 +132,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.mysql.tableEngineKeyword' => 'ENGINE',
), $this->getBuildProperties($input->getOption('input-dir') . '/build.properties')));
- $filesystem = $this->getFilesystem();
- $filesystem->mkdir($input->getOption('output-dir'));
+ $this->createDirectory($input->getOption('output-dir'));
$manager = new ModelManager();
+ $manager->setFilesystem($this->getFilesystem());
$manager->setGeneratorConfig($generatorConfig);
$manager->setSchemas($this->getSchemas($input->getOption('input-dir')));
$manager->setLoggerClosure(function($message) use ($input, $output) {
View
3 src/Propel/Generator/Command/SqlBuildCommand.php
@@ -63,8 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.mysql.tableEngineKeyword' => 'ENGINE',
), $this->getBuildProperties($input->getOption('input-dir') . '/build.properties')));
- $filesystem = $this->getFilesystem();
- $filesystem->mkdir($input->getOption('output-dir'));
+ $this->createDirectory($input->getOption('output-dir'));
$manager = new SqlManager();
$manager->setValidate($input->getOption('validate'));
View
12 src/Propel/Generator/Manager/ModelManager.php
@@ -10,8 +10,8 @@
namespace Propel\Generator\Manager;
+use Symfony\Component\Filesystem\Filesystem;
use Propel\Generator\Builder\Om\AbstractOMBuilder;
-use Propel\Generator\Util\Filesystem;
/**
* This manager creates the Object Model classes based on the XML schema file.
@@ -20,6 +20,13 @@
*/
class ModelManager extends AbstractManager
{
+ private $filesystem;
+
+ public function setFilesystem(Filesystem $filesystem)
+ {
+ $this->filesystem = $filesystem;
+ }
+
public function build()
{
$this->validate();
@@ -140,8 +147,7 @@ protected function doBuild(AbstractOMBuilder $builder, $overwrite = true)
$path = $builder->getClassFilePath();
$file = new \SplFileInfo($this->getWorkingDirectory() . DIRECTORY_SEPARATOR . $path);
- $filesystem = new Filesystem();
- $filesystem->mkdir($file->getPath());
+ $this->filesystem->mkdir($file->getPath());
// skip files already created once
if ($file->isFile() && !$overwrite) {
Something went wrong with that request. Please try again.