This commit is contained in:
Toni Uebernickel 2016-01-23 14:44:00 +01:00
parent eca10b8722
commit fe65d848ca
2 changed files with 10 additions and 15 deletions

View file

@ -7,18 +7,14 @@
*
* @license MIT License
*/
namespace Propel\PropelBundle\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\Output;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Propel\PropelBundle\Command\AbstractCommand;
/**
* SqlBuildCommand.
*
@ -55,14 +51,14 @@ EOT
$finder = new Finder();
$filesystem = new Filesystem();
$sqlDir = $this->getApplication()->getKernel()->getCacheDir(). DIRECTORY_SEPARATOR .'propel'.DIRECTORY_SEPARATOR. 'sql';
$sqlDir = $this->getApplication()->getKernel()->getCacheDir().DIRECTORY_SEPARATOR.'propel'.DIRECTORY_SEPARATOR.'sql';
$filesystem->remove($sqlDir);
$filesystem->mkdir($sqlDir);
// Execute the task
$ret = $this->callPhing('build-sql', array(
'propel.sql.dir' => $sqlDir
'propel.sql.dir' => $sqlDir,
));
// Show the list of generated files
@ -72,7 +68,7 @@ EOT
$nbFiles = 0;
foreach ($files as $file) {
$fileExt = pathinfo($file->getFilename(), PATHINFO_EXTENSION);
$finalLocation = $sqlDir. DIRECTORY_SEPARATOR. $file->getFilename();
$finalLocation = $sqlDir.DIRECTORY_SEPARATOR.$file->getFilename();
if ($fileExt === 'map' && $filesystem->exists($finalLocation)) {
$this->mergeMapFiles($finalLocation, (string) $file);
@ -81,7 +77,7 @@ EOT
$this->writeNewFile($output, (string) $file);
if ('sql' === $fileExt) {
$nbFiles++;
++$nbFiles;
}
}
@ -92,7 +88,7 @@ EOT
$this->writeSection($output, array(
'[Propel] Error',
'',
'An error has occured during the "propel:sql:build" command process. To get more details, run the command with the "--verbose" option.'
'An error has occured during the "propel:sql:build" command process. To get more details, run the command with the "--verbose" option.',
), 'fg=white;bg=red');
}
}
@ -104,16 +100,17 @@ EOT
* @param string $target target map filename
* @param string $generated generated map filename
*
* @return boolean result
* @return bool
*/
protected function mergeMapFiles($target, $generated)
{
if(($targetContent = file($target)) === false)
if (false === ($targetContent = file($target))) {
return false;
if(($generatedContent = file($generated)) === false)
}
if (false === ($generatedContent = file($generated))) {
return false;
}
$targetContent = array_merge($generatedContent, array_diff($targetContent, $generatedContent));

View file

@ -7,10 +7,8 @@
*
* @license MIT License
*/
namespace Propel\PropelBundle\Command;
use Propel\PropelBundle\Command\AbstractCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;