Skip to content

Commit eca10b8

Browse files
committed
generate SQL files into cache directory
This fixes propelorm#376.
1 parent 93dc571 commit eca10b8

2 files changed

Lines changed: 6 additions & 17 deletions

File tree

Command/SqlBuildCommand.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
5555
$finder = new Finder();
5656
$filesystem = new Filesystem();
5757

58-
$sqlDir = $this->getApplication()->getKernel()->getRootDir(). DIRECTORY_SEPARATOR . 'propel'. DIRECTORY_SEPARATOR . 'sql';
59-
$cacheDir = $this->getApplication()->getKernel()->getCacheDir(). DIRECTORY_SEPARATOR . 'sql';
58+
$sqlDir = $this->getApplication()->getKernel()->getCacheDir(). DIRECTORY_SEPARATOR .'propel'.DIRECTORY_SEPARATOR. 'sql';
6059

61-
$filesystem->remove($cacheDir);
62-
$filesystem->mkdir($cacheDir);
63-
64-
if (!$filesystem->exists($sqlDir)) {
65-
$filesystem->mkdir($sqlDir);
66-
}
60+
$filesystem->remove($sqlDir);
61+
$filesystem->mkdir($sqlDir);
6762

6863
// Execute the task
6964
$ret = $this->callPhing('build-sql', array(
70-
'propel.sql.dir' => $cacheDir
65+
'propel.sql.dir' => $sqlDir
7166
));
7267

7368
// Show the list of generated files
7469
if (true === $ret) {
75-
$files = $finder->name('*')->in($cacheDir);
70+
$files = $finder->name('*')->in($sqlDir);
7671

7772
$nbFiles = 0;
7873
foreach ($files as $file) {
@@ -81,9 +76,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
8176

8277
if ($fileExt === 'map' && $filesystem->exists($finalLocation)) {
8378
$this->mergeMapFiles($finalLocation, (string) $file);
84-
} else {
85-
$filesystem->remove($finalLocation);
86-
$filesystem->rename((string) $file, $finalLocation);
8779
}
8880

8981
$this->writeNewFile($output, (string) $file);

Command/SqlInsertCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ protected function configure()
5252
*/
5353
protected function execute(InputInterface $input, OutputInterface $output)
5454
{
55-
// Bad require but needed :(
56-
require_once $this->getContainer()->getParameter('propel.path') . '/generator/lib/util/PropelSqlManager.php';
57-
5855
if ($input->getOption('force')) {
5956
$connections = $this->getConnections();
6057
$sqlDir = $this->getSqlDir();
@@ -80,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8077

8178
protected function getSqlDir()
8279
{
83-
return sprintf('%s/propel/sql', $this->getApplication()->getKernel()->getRootDir());
80+
return sprintf('%s/propel/sql', $this->getApplication()->getKernel()->getCacheDir());
8481
}
8582

8683
/**

0 commit comments

Comments
 (0)