@@ -48,56 +48,32 @@ public function execute($configFiles)
4848 throw new sfParseException (sprintf ('Configuration file "%s" specifies nonexistent or unreadable file "%s". ' , $ configFiles [0 ], $ file ));
4949 }
5050
51- $ contents = file_get_contents ($ file );
51+ if (sfConfig::get ('sf_debug ' ))
52+ {
53+ $ contents = file_get_contents ($ file );
5254
53- // strip comments (not in debug mode)
54- if (!sfConfig::get ('sf_debug ' ))
55+ // replace windows and mac format with unix format
56+ $ contents = str_replace ("\r" , PHP_EOL , $ contents );
57+ }
58+ else
5559 {
56- $ contents = sfToolkit::stripComments ($ contents );
60+ // strip whitespaces and comments
61+ $ contents = php_strip_whitespace ($ file );
5762 }
5863
59- // insert configuration files
60- /* $contents = preg_replace_callback(array('#(require|include)(_once)?\((sfContext::getInstance\(\)\->getConfigCache\(\)|\$configCache)->checkConfig\(\'config/([^\']+)\'\)\);#m',
61- '#()()(sfContext::getInstance\(\)\->getConfigCache\(\)|\$configCache)->import\(\'config/([^\']+)\'(, false)?\);#m'),
62- array($this, 'insertConfigFileCallback'), $contents);
63- */
6464 // strip php tags
65- $ contents = sfToolkit::pregtr ($ contents , array ('/^\s*<\?(php)?/m ' => '' ,
66- '/^\s*\?>/m ' => '' ));
67-
68- // replace windows and mac format with unix format
69- $ contents = str_replace ("\r" , "\n" , $ contents );
70-
71- // replace multiple new lines with a single newline
72- $ contents = preg_replace (array ('/\s+$/Sm ' , '/\n+/S ' ), "\n" , $ contents );
65+ $ contents = sfToolkit::pregtr ($ contents , array ('/^\s*<\?(php)?/m ' => '' , '/^\s*\?>/m ' => '' ));
7366
7467 // append file data
75- $ data .= "\n" .$ contents ;
68+ $ data .= PHP_EOL .$ contents ;
7669 }
7770
7871 // compile data
79- $ retval = sprintf ("<?php \n" .
80- "// auto-generated by sfCompileConfigHandler \n" .
81- "// date: %s \n%s \n" ,
72+ return sprintf ('<?php ' .PHP_EOL .
73+ '// auto-generated by sfCompileConfigHandler ' .PHP_EOL .
74+ '// date: %s ' .PHP_EOL .
75+ '%s ' .PHP_EOL ,
8276 date ('Y/m/d H:i:s ' ), $ data );
83-
84- return $ retval ;
85- }
86-
87- /**
88- * Callback for configuration file insertion in the cache.
89- *
90- */
91- protected function insertConfigFileCallback ($ matches )
92- {
93- $ configFile = 'config/ ' .$ matches [4 ];
94-
95- $ configCache = sfContext::getInstance ()->getConfigCache ();
96- $ configCache ->checkConfig ($ configFile );
97-
98- $ config = "// ' $ configFile' config file \n" .file_get_contents ($ configCache ->getCacheName ($ configFile ));
99-
100- return $ config ;
10177 }
10278
10379 /**
0 commit comments