generate SQL files into cache directory

This fixes #376.
This commit is contained in:
Toni Uebernickel 2016-01-23 14:23:14 +01:00
parent 93dc571a04
commit eca10b8722
2 changed files with 6 additions and 17 deletions

View file

@ -55,24 +55,19 @@ EOT
$finder = new Finder();
$filesystem = new Filesystem();
$sqlDir = $this->getApplication()->getKernel()->getRootDir(). DIRECTORY_SEPARATOR . 'propel'. DIRECTORY_SEPARATOR . 'sql';
$cacheDir = $this->getApplication()->getKernel()->getCacheDir(). DIRECTORY_SEPARATOR . 'sql';
$sqlDir = $this->getApplication()->getKernel()->getCacheDir(). DIRECTORY_SEPARATOR .'propel'.DIRECTORY_SEPARATOR. 'sql';
$filesystem->remove($cacheDir);
$filesystem->mkdir($cacheDir);
if (!$filesystem->exists($sqlDir)) {
$filesystem->mkdir($sqlDir);
}
$filesystem->remove($sqlDir);
$filesystem->mkdir($sqlDir);
// Execute the task
$ret = $this->callPhing('build-sql', array(
'propel.sql.dir' => $cacheDir
'propel.sql.dir' => $sqlDir
));
// Show the list of generated files
if (true === $ret) {
$files = $finder->name('*')->in($cacheDir);
$files = $finder->name('*')->in($sqlDir);
$nbFiles = 0;
foreach ($files as $file) {
@ -81,9 +76,6 @@ EOT
if ($fileExt === 'map' && $filesystem->exists($finalLocation)) {
$this->mergeMapFiles($finalLocation, (string) $file);
} else {
$filesystem->remove($finalLocation);
$filesystem->rename((string) $file, $finalLocation);
}
$this->writeNewFile($output, (string) $file);

View file

@ -52,9 +52,6 @@ EOT
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// Bad require but needed :(
require_once $this->getContainer()->getParameter('propel.path') . '/generator/lib/util/PropelSqlManager.php';
if ($input->getOption('force')) {
$connections = $this->getConnections();
$sqlDir = $this->getSqlDir();
@ -80,7 +77,7 @@ EOT
protected function getSqlDir()
{
return sprintf('%s/propel/sql', $this->getApplication()->getKernel()->getRootDir());
return sprintf('%s/propel/sql', $this->getApplication()->getKernel()->getCacheDir());
}
/**