diff --git a/Command/MigrationDiffCommand.php b/Command/MigrationDiffCommand.php index d72c3bf..c8936d9 100644 --- a/Command/MigrationDiffCommand.php +++ b/Command/MigrationDiffCommand.php @@ -54,7 +54,7 @@ class MigrationDiffCommand extends WrappedCommand */ protected function getSubCommandArguments(InputInterface $input) { - $defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations'; + $defaultOutputDir = $this->getContainer()->getParameter('propel.configuration')['paths']['migrationDir']; return array( '--connection' => $this->getConnections($input->getOption('connection')), diff --git a/Command/MigrationDownCommand.php b/Command/MigrationDownCommand.php index ba85b95..5cce837 100644 --- a/Command/MigrationDownCommand.php +++ b/Command/MigrationDownCommand.php @@ -52,7 +52,7 @@ class MigrationDownCommand extends WrappedCommand */ protected function getSubCommandArguments(InputInterface $input) { - $defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations'; + $defaultOutputDir = $this->getContainer()->getParameter('propel.configuration')['paths']['migrationDir']; return array( '--connection' => $this->getConnections($input->getOption('connection')), diff --git a/Command/MigrationMigrateCommand.php b/Command/MigrationMigrateCommand.php index 0d475b3..b890624 100644 --- a/Command/MigrationMigrateCommand.php +++ b/Command/MigrationMigrateCommand.php @@ -52,7 +52,7 @@ class MigrationMigrateCommand extends WrappedCommand */ protected function getSubCommandArguments(InputInterface $input) { - $defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations'; + $defaultOutputDir = $this->getContainer()->getParameter('propel.configuration')['paths']['migrationDir']; return array( '--connection' => $this->getConnections($input->getOption('connection')), diff --git a/Command/MigrationStatusCommand.php b/Command/MigrationStatusCommand.php index a6b5c07..114b643 100644 --- a/Command/MigrationStatusCommand.php +++ b/Command/MigrationStatusCommand.php @@ -50,7 +50,7 @@ class MigrationStatusCommand extends WrappedCommand */ protected function getSubCommandArguments(InputInterface $input) { - $defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations'; + $defaultOutputDir = $this->getContainer()->getParameter('propel.configuration')['paths']['migrationDir']; return array( '--connection' => $this->getConnections($input->getOption('connection')), diff --git a/Command/MigrationUpCommand.php b/Command/MigrationUpCommand.php index 546c31c..c550b84 100644 --- a/Command/MigrationUpCommand.php +++ b/Command/MigrationUpCommand.php @@ -52,7 +52,7 @@ class MigrationUpCommand extends WrappedCommand */ protected function getSubCommandArguments(InputInterface $input) { - $defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations'; + $defaultOutputDir = $this->getContainer()->getParameter('propel.configuration')['paths']['migrationDir']; return array( '--connection' => $this->getConnections($input->getOption('connection')), diff --git a/Command/SqlBuildCommand.php b/Command/SqlBuildCommand.php index 0a07fa1..a71f285 100644 --- a/Command/SqlBuildCommand.php +++ b/Command/SqlBuildCommand.php @@ -47,7 +47,7 @@ class SqlBuildCommand extends WrappedCommand */ protected function getSubCommandArguments(InputInterface $input) { - $defaultSqlDir = sprintf('%s/propel/sql', $this->getApplication()->getKernel()->getRootDir()); + $defaultSqlDir = $this->getContainer()->getParameter('propel.configuration')['paths']['sqlDir']; return array( '--connection' => $this->getConnections($input->getOption('connection')), diff --git a/Command/SqlInsertCommand.php b/Command/SqlInsertCommand.php index 564ef52..db23a46 100644 --- a/Command/SqlInsertCommand.php +++ b/Command/SqlInsertCommand.php @@ -59,7 +59,7 @@ class SqlInsertCommand extends WrappedCommand */ protected function getSubCommandArguments(InputInterface $input) { - $defaultSqlDir = sprintf('%s/propel/sql', $this->getApplication()->getKernel()->getRootDir()); + $defaultSqlDir = $this->getContainer()->getParameter('propel.configuration')['paths']['sqlDir']; return array( '--connection' => $this->getConnections($input->getOption('connection')), diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 0d637b6..4cc058e 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -19,10 +19,29 @@ use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; class Configuration extends PropelConfiguration { private $debug; + private $defaultDir; - public function __construct($debug = true) + public function __construct($debug, $kernelDir) { $this->debug = $debug; + $this->defaultDir = $kernelDir.'/propel'; + } + + protected function addPathsSection(ArrayNodeDefinition $node) + { + $node + ->children() + ->arrayNode('paths') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('schemaDir')->defaultValue($this->defaultDir)->end() + ->scalarNode('sqlDir')->defaultValue($this->defaultDir.'/sql')->end() + ->scalarNode('migrationDir')->defaultValue($this->defaultDir.'/migrations')->end() + ->scalarNode('composerDir')->defaultNull()->end() + ->end() + ->end() + ->end() + ; } protected function addRuntimeSection(ArrayNodeDefinition $node) diff --git a/DependencyInjection/PropelExtension.php b/DependencyInjection/PropelExtension.php index 534b472..62b5c68 100644 --- a/DependencyInjection/PropelExtension.php +++ b/DependencyInjection/PropelExtension.php @@ -58,7 +58,7 @@ class PropelExtension extends Extension public function getConfiguration(array $config, ContainerBuilder $container) { - return new Configuration($container->getParameter('kernel.debug')); + return new Configuration($container->getParameter('kernel.debug'), $container->getParameter('kernel.root_dir')); } /**