Skip to content

Commit

Permalink
Merge pull request #295 from hhamon/commands_refactoring
Browse files Browse the repository at this point in the history
[Generator] removed Filesystem class. Propel now relies on the standalon...
  • Loading branch information
willdurand committed Aug 22, 2012
2 parents 338752a + cd22336 commit a24f5fe
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 300 deletions.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -21,7 +21,8 @@
"symfony/console": "2.1.*",
"monolog/monolog": "1.0.*",
"symfony/finder": "2.1.*",
"symfony/validator": "2.1.*"
"symfony/validator": "2.1.*",
"symfony/filesystem": "2.1.*"
},
"require-dev": {
"behat/behat": "2.4@stable"
Expand Down
19 changes: 17 additions & 2 deletions src/Propel/Generator/Command/AbstractCommand.php
Expand Up @@ -13,7 +13,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Finder\Finder;

use Symfony\Component\Filesystem\Filesystem;
use Propel\Generator\Exception\RuntimeException;

/**
Expand All @@ -22,9 +22,10 @@
abstract class AbstractCommand extends Command
{
const DEFAULT_INPUT_DIRECTORY = '.';

const DEFAULT_PLATFORM = 'MysqlPlatform';

protected $filesystem;

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -72,6 +73,20 @@ protected function getSchemas($directory)
);
}

/**
* Returns a Filesystem instance.
*
* @return Filesystem
*/
protected function getFilesystem()
{
if (null === $this->filesystem) {
$this->filesystem = new Filesystem();
}

return $this->filesystem;
}

protected function parseConnection($connection)
{
$pos = strpos($connection, '=');
Expand Down
6 changes: 2 additions & 4 deletions src/Propel/Generator/Command/ConfigConvertXmlCommand.php
Expand Up @@ -10,16 +10,14 @@

namespace Propel\Generator\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\Output;
use Propel\Generator\Config\XmlToArrayConverter;
use Propel\Generator\Config\ArrayToPhpConverter;
use Propel\Generator\Util\Filesystem;

class ConfigConvertXmlCommand extends Command
class ConfigConvertXmlCommand extends AbstractCommand
{
const DEFAULT_INPUT_DIRECTORY = '.';
const DEFAULT_INPUT_FILE = 'runtime-conf.xml';
Expand Down Expand Up @@ -51,7 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
throw new \RuntimeException(sprintf('Unable to find the "%s" configuration file', $inputFilePath));
}

$filesystem = new Filesystem();
$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')));
};
Expand Down
3 changes: 1 addition & 2 deletions src/Propel/Generator/Command/DatabaseReverseCommand.php
Expand Up @@ -17,7 +17,6 @@
use Symfony\Component\Console\Output\Output;
use Propel\Generator\Config\GeneratorConfig;
use Propel\Generator\Manager\ReverseManager;
use Propel\Generator\Util\Filesystem;

/**
* @author William Durand <william.durand1@gmail.com>
Expand Down Expand Up @@ -61,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.reverse.parser.class' => sprintf('\\Propel\\Generator\\Reverse\\%sSchemaParser', $vendor),
));

$filesystem = new Filesystem();
$filesystem = $this->getFilesystem();
$filesystem->mkdir($input->getOption('output-dir'));

$manager = new ReverseManager();
Expand Down
3 changes: 1 addition & 2 deletions src/Propel/Generator/Command/GraphvizGenerateCommand.php
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Output\Output;
use Propel\Generator\Config\GeneratorConfig;
use Propel\Generator\Manager\GraphvizManager;
use Propel\Generator\Util\Filesystem;

/**
* @author William Durand <william.durand1@gmail.com>
Expand Down Expand Up @@ -49,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.packageObjectModel' => true,
));

$filesystem = new Filesystem();
$filesystem = $this->getFilesystem();
$filesystem->mkdir($input->getOption('output-dir'));

$manager = new GraphvizManager();
Expand Down
3 changes: 1 addition & 2 deletions src/Propel/Generator/Command/MigrationDiffCommand.php
Expand Up @@ -18,7 +18,6 @@
use Propel\Generator\Exception\RuntimeException;
use Propel\Generator\Manager\MigrationManager;
use Propel\Generator\Model\IdMethod;
use Propel\Generator\Util\Filesystem;

/**
* @author William Durand <william.durand1@gmail.com>
Expand Down Expand Up @@ -55,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.platform.class' => $input->getOption('platform'),
));

$filesystem = new Filesystem();
$filesystem = $this->getFilesystem();
$filesystem->mkdir($input->getOption('output-dir'));

$manager = new MigrationManager();
Expand Down
3 changes: 1 addition & 2 deletions src/Propel/Generator/Command/MigrationDownCommand.php
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Output\Output;
use Propel\Generator\Config\GeneratorConfig;
use Propel\Generator\Manager\MigrationManager;
use Propel\Generator\Util\Filesystem;

/**
* @author William Durand <william.durand1@gmail.com>
Expand Down Expand Up @@ -52,7 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.platform.class' => $input->getOption('platform'),
));

$filesystem = new Filesystem();
$filesystem = $this->getFilesystem();
$filesystem->mkdir($input->getOption('output-dir'));

$manager = new MigrationManager();
Expand Down
3 changes: 1 addition & 2 deletions src/Propel/Generator/Command/MigrationMigrateCommand.php
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Output\Output;
use Propel\Generator\Config\GeneratorConfig;
use Propel\Generator\Manager\MigrationManager;
use Propel\Generator\Util\Filesystem;

/**
* @author William Durand <william.durand1@gmail.com>
Expand Down Expand Up @@ -52,7 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.platform.class' => $input->getOption('platform'),
));

$filesystem = new Filesystem();
$filesystem = $this->getFilesystem();
$filesystem->mkdir($input->getOption('output-dir'));

$manager = new MigrationManager();
Expand Down
3 changes: 1 addition & 2 deletions src/Propel/Generator/Command/MigrationStatusCommand.php
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Output\Output;
use Propel\Generator\Config\GeneratorConfig;
use Propel\Generator\Manager\MigrationManager;
use Propel\Generator\Util\Filesystem;

/**
* @author William Durand <william.durand1@gmail.com>
Expand Down Expand Up @@ -52,7 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.platform.class' => $input->getOption('platform'),
));

$filesystem = new Filesystem();
$filesystem = $this->getFilesystem();
$filesystem->mkdir($input->getOption('output-dir'));

$manager = new MigrationManager();
Expand Down
3 changes: 1 addition & 2 deletions src/Propel/Generator/Command/MigrationUpCommand.php
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Output\Output;
use Propel\Generator\Config\GeneratorConfig;
use Propel\Generator\Manager\MigrationManager;
use Propel\Generator\Util\Filesystem;

/**
* @author William Durand <william.durand1@gmail.com>
Expand Down Expand Up @@ -52,7 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.platform.class' => $input->getOption('platform'),
));

$filesystem = new Filesystem();
$filesystem = $this->getFilesystem();
$filesystem->mkdir($input->getOption('output-dir'));

$manager = new MigrationManager();
Expand Down
3 changes: 1 addition & 2 deletions src/Propel/Generator/Command/ModelBuildCommand.php
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Output\Output;
use Propel\Generator\Config\GeneratorConfig;
use Propel\Generator\Manager\ModelManager;
use Propel\Generator\Util\Filesystem;

/**
* @author Florian Klein <florian.klein@free.fr>
Expand Down Expand Up @@ -133,7 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.mysql.tableEngineKeyword' => 'ENGINE',
), $this->getBuildProperties($input->getOption('input-dir') . '/build.properties')));

$filesystem = new Filesystem();
$filesystem = $this->getFilesystem();
$filesystem->mkdir($input->getOption('output-dir'));

$manager = new ModelManager();
Expand Down
3 changes: 1 addition & 2 deletions src/Propel/Generator/Command/SqlBuildCommand.php
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Console\Output\Output;
use Propel\Generator\Config\GeneratorConfig;
use Propel\Generator\Manager\SqlManager;
use Propel\Generator\Util\Filesystem;

/**
* @author William Durand <william.durand1@gmail.com>
Expand Down Expand Up @@ -64,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.mysql.tableEngineKeyword' => 'ENGINE',
), $this->getBuildProperties($input->getOption('input-dir') . '/build.properties')));

$filesystem = new Filesystem();
$filesystem = $this->getFilesystem();
$filesystem->mkdir($input->getOption('output-dir'));

$manager = new SqlManager();
Expand Down

0 comments on commit a24f5fe

Please sign in to comment.