Allow to configure sql/migrations dir (#459)

This commit is contained in:
Gregor Harlan 2017-08-31 12:26:56 +02:00 committed by Marc J. Schmidt
parent efada49f15
commit 59f3b4a738
9 changed files with 28 additions and 9 deletions

View file

@ -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')),

View file

@ -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')),

View file

@ -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')),

View file

@ -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')),

View file

@ -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')),

View file

@ -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')),

View file

@ -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')),

View file

@ -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)

View file

@ -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'));
}
/**