123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- class sfCompileConfigHandler extends sfYamlConfigHandler
- {
-
- public function execute($configFiles)
- {
-
- $config = self::getConfiguration($configFiles);
-
- $data = '';
-
- foreach ($config as $file)
- {
- if (!is_readable($file))
- {
-
- throw new sfParseException(sprintf('Configuration file "%s" specifies nonexistent or unreadable file "%s".', $configFiles[0], $file));
- }
- $contents = file_get_contents($file);
-
- if (!sfConfig::get('sf_debug'))
- {
- $contents = sfToolkit::stripComments($contents);
- }
-
-
- $contents = sfToolkit::pregtr($contents, array('/^\s*<\?(php)?/m' => '',
- '/^\s*\?>/m' => ''));
-
- $contents = str_replace("\r", "\n", $contents);
-
- $contents = preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $contents);
-
- $data .= "\n".$contents;
- }
-
- $retval = sprintf("<?php\n".
- "// auto-generated by sfCompileConfigHandler\n".
- "// date: %s\n%s\n",
- date('Y/m/d H:i:s'), $data);
-
- file_put_contents(sfConfig::get('sf_config_cache_dir').'/VERSION', SYMFONY_VERSION);
- return $retval;
- }
-
- protected function insertConfigFileCallback($matches)
- {
- $configFile = 'config/'.$matches[4];
- $configCache = sfContext::getInstance()->getConfigCache();
- $configCache->checkConfig($configFile);
- $config = "// '$configFile' config file\n".file_get_contents($configCache->getCacheName($configFile));
- return $config;
- }
-
- static public function getConfiguration(array $configFiles)
- {
- $config = array();
- foreach ($configFiles as $configFile)
- {
- $config = array_merge($config, self::parseYaml($configFile));
- }
- return self::replacePath(self::replaceConstants($config));
- }
- }
|