77 *
88 * @license MIT License
99 */
10-
1110namespace Propel \PropelBundle \Command ;
1211
1312use Symfony \Component \Console \Input \InputInterface ;
1413use Symfony \Component \Console \Input \InputOption ;
1514use Symfony \Component \Console \Output \OutputInterface ;
16- use Symfony \Component \Console \Output \Output ;
1715use Symfony \Component \Filesystem \Filesystem ;
1816use Symfony \Component \Finder \Finder ;
1917
20- use Propel \PropelBundle \Command \AbstractCommand ;
21-
2218/**
2319 * SqlBuildCommand.
2420 *
@@ -55,41 +51,33 @@ protected function execute(InputInterface $input, OutputInterface $output)
5551 $ finder = new Finder ();
5652 $ filesystem = new Filesystem ();
5753
58- $ sqlDir = $ this ->getApplication ()->getKernel ()->getRootDir (). DIRECTORY_SEPARATOR . 'propel ' . DIRECTORY_SEPARATOR . 'sql ' ;
59- $ cacheDir = $ this ->getApplication ()->getKernel ()->getCacheDir (). DIRECTORY_SEPARATOR . 'sql ' ;
54+ $ sqlDir = $ this ->getApplication ()->getKernel ()->getCacheDir ().DIRECTORY_SEPARATOR .'propel ' .DIRECTORY_SEPARATOR .'sql ' ;
6055
61- $ filesystem ->remove ($ cacheDir );
62- $ filesystem ->mkdir ($ cacheDir );
63-
64- if (!$ filesystem ->exists ($ sqlDir )) {
65- $ filesystem ->mkdir ($ sqlDir );
66- }
56+ $ filesystem ->remove ($ sqlDir );
57+ $ filesystem ->mkdir ($ sqlDir );
6758
6859 // Execute the task
6960 $ ret = $ this ->callPhing ('build-sql ' , array (
70- 'propel.sql.dir ' => $ cacheDir
61+ 'propel.sql.dir ' => $ sqlDir ,
7162 ));
7263
7364 // Show the list of generated files
7465 if (true === $ ret ) {
75- $ files = $ finder ->name ('* ' )->in ($ cacheDir );
66+ $ files = $ finder ->name ('* ' )->in ($ sqlDir );
7667
7768 $ nbFiles = 0 ;
7869 foreach ($ files as $ file ) {
7970 $ fileExt = pathinfo ($ file ->getFilename (), PATHINFO_EXTENSION );
80- $ finalLocation = $ sqlDir . DIRECTORY_SEPARATOR . $ file ->getFilename ();
71+ $ finalLocation = $ sqlDir .DIRECTORY_SEPARATOR .$ file ->getFilename ();
8172
8273 if ($ fileExt === 'map ' && $ filesystem ->exists ($ finalLocation )) {
8374 $ this ->mergeMapFiles ($ finalLocation , (string ) $ file );
84- } else {
85- $ filesystem ->remove ($ finalLocation );
86- $ filesystem ->rename ((string ) $ file , $ finalLocation );
8775 }
8876
8977 $ this ->writeNewFile ($ output , (string ) $ file );
9078
9179 if ('sql ' === $ fileExt ) {
92- $ nbFiles ++ ;
80+ ++ $ nbFiles ;
9381 }
9482 }
9583
@@ -100,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
10088 $ this ->writeSection ($ output , array (
10189 '[Propel] Error ' ,
10290 '' ,
103- 'An error has occured during the "propel:sql:build" command process. To get more details, run the command with the "--verbose" option. '
91+ 'An error has occured during the "propel:sql:build" command process. To get more details, run the command with the "--verbose" option. ' ,
10492 ), 'fg=white;bg=red ' );
10593 }
10694 }
@@ -112,16 +100,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
112100 * @param string $target target map filename
113101 * @param string $generated generated map filename
114102 *
115- * @return boolean result
103+ * @return bool
116104 */
117105 protected function mergeMapFiles ($ target , $ generated )
118106 {
119- if (($ targetContent = file ($ target )) === false )
120-
107+ if (false === ($ targetContent = file ($ target ))) {
121108 return false ;
122- if (( $ generatedContent = file ( $ generated )) === false )
109+ }
123110
111+ if (false === ($ generatedContent = file ($ generated ))) {
124112 return false ;
113+ }
125114
126115 $ targetContent = array_merge ($ generatedContent , array_diff ($ targetContent , $ generatedContent ));
127116
0 commit comments