Changeset 843
- Timestamp:
- 02/17/06 12:03:43 (2 years ago)
- Files:
-
- trunk/data/config/config_handlers.yml (modified) (3 diffs)
- trunk/data/config/security.yml (deleted)
- trunk/data/config/view.yml (deleted)
- trunk/lib/action/sfAction.class.php (modified) (1 diff)
- trunk/lib/config/sfAutoloadConfigHandler.class.php (modified) (2 diffs)
- trunk/lib/config/sfCacheConfigHandler.class.php (modified) (6 diffs)
- trunk/lib/config/sfCompileConfigHandler.class.php (modified) (1 diff)
- trunk/lib/config/sfConfigCache.class.php (modified) (9 diffs)
- trunk/lib/config/sfConfigHandler.class.php (modified) (1 diff)
- trunk/lib/config/sfDatabaseConfigHandler.class.php (modified) (1 diff)
- trunk/lib/config/sfDefineEnvironmentConfigHandler.class.php (modified) (6 diffs)
- trunk/lib/config/sfFactoryConfigHandler.class.php (modified) (1 diff)
- trunk/lib/config/sfFilterConfigHandler.class.php (modified) (1 diff)
- trunk/lib/config/sfGeneratorConfigHandler.class.php (modified) (3 diffs)
- trunk/lib/config/sfPhpConfigHandler.class.php (modified) (1 diff)
- trunk/lib/config/sfRootConfigHandler.class.php (modified) (1 diff)
- trunk/lib/config/sfRoutingConfigHandler.class.php (modified) (1 diff)
- trunk/lib/config/sfSecurityConfigHandler.class.php (modified) (2 diffs)
- trunk/lib/config/sfValidatorConfigHandler.class.php (modified) (2 diffs)
- trunk/lib/config/sfViewConfigHandler.class.php (modified) (2 diffs)
- trunk/lib/config/sfYamlConfigHandler.class.php (modified) (5 diffs)
- trunk/lib/controller/sfController.class.php (modified) (5 diffs)
- trunk/lib/filter/sfCacheFilter.class.php (modified) (1 diff)
- trunk/lib/symfony.php (modified) (1 diff)
- trunk/lib/view/sfMailView.class.php (modified) (1 diff)
- trunk/test/config/sfDefineEnvironmentConfigHandlerTest.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/data/config/config_handlers.yml
r665 r843 1 autoload.yml:1 config/autoload.yml: 2 2 class: sfAutoloadConfigHandler 3 3 4 php.yml:4 config/php.yml: 5 5 class: sfPhpConfigHandler 6 6 7 databases.yml:7 config/databases.yml: 8 8 class: sfDatabaseConfigHandler 9 9 10 settings.yml:10 config/settings.yml: 11 11 class: sfDefineEnvironmentConfigHandler 12 12 param: 13 13 prefix: sf_ 14 14 15 app.yml:15 config/app.yml: 16 16 class: sfDefineEnvironmentConfigHandler 17 17 param: 18 18 prefix: app_ 19 19 20 factories.yml:20 config/factories.yml: 21 21 class: sfFactoryConfigHandler 22 22 23 bootstrap_compile.yml:23 config/bootstrap_compile.yml: 24 24 class: sfCompileConfigHandler 25 25 26 co re_compile.yml:26 config/core_compile.yml: 27 27 class: sfCompileConfigHandler 28 28 29 filters.yml:29 config/filters.yml: 30 30 class: sfFilterConfigHandler 31 31 32 logging.yml:32 config/logging.yml: 33 33 class: sfDefineEnvironmentConfigHandler 34 34 param: 35 35 prefix: sf_logging_ 36 37 config/routing.yml: 38 class: sfRoutingConfigHandler 39 40 config/i18n.yml: 41 class: sfDefineEnvironmentConfigHandler 42 param: 43 prefix: sf_i18n_ 36 44 37 45 modules/*/config/generator.yml: … … 45 53 param: 46 54 prefix: sf_mailer_ 55 module: yes 47 56 48 57 modules/*/config/security.yml: … … 59 68 param: 60 69 prefix: mod_ 61 62 routing.yml: 63 class: sfRoutingConfigHandler 64 65 i18n.yml: 66 class: sfDefineEnvironmentConfigHandler 67 param: 68 prefix: sf_i18n_ 70 module: yes trunk/lib/action/sfAction.class.php
r716 r843 57 57 58 58 // include security configuration 59 require(sfConfigCache::getInstance()->checkConfig( 'modules/'.$this->getModuleName().'/'.sfConfig::get('sf_app_module_config_dir_name').'/security.yml', true, array('moduleName' => $this->getModuleName())));59 require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$this->getModuleName().'/'.sfConfig::get('sf_app_module_config_dir_name').'/security.yml', true)); 60 60 61 61 return true; trunk/lib/config/sfAutoloadConfigHandler.class.php
r717 r843 30 30 * @throws sfParseException If a requested configuration file is improperly formatted. 31 31 */ 32 public function execute($configFile , $param = array())32 public function execute($configFiles) 33 33 { 34 34 // set our required categories list and initialize our handler … … 38 38 39 39 // parse the yaml 40 $config = $this->parseYaml($configFile); 41 42 // get symfyon configuration 43 $symfonyConfigFile = sfConfig::get('sf_symfony_data_dir').'/config/'.basename($configFile); 44 $symfonyConfig = is_readable($symfonyConfigFile) ? $this->parseYaml($symfonyConfigFile) : array(); 45 46 // merge with autoload configurations 47 $myConfig = sfToolkit::arrayDeepMerge($symfonyConfig, $config); 40 $myConfig = $this->parseYamls($configFiles); 48 41 49 42 // init our data array trunk/lib/config/sfCacheConfigHandler.class.php
r746 r843 33 33 * @throws <b>sfInitializationException</b> If a cache.yml key check fails. 34 34 */ 35 public function execute($configFile , $param = array())35 public function execute($configFiles) 36 36 { 37 37 // set our required categories list and initialize our handler … … 40 40 41 41 // parse the yaml 42 $ this->yamlConfig = $this->parseYaml($configFile);42 $myConfig = $this->parseYamls($configFiles); 43 43 44 // init our data array 45 $data = array(); 44 $myConfig['all'] = sfToolkit::arrayDeepMerge( 45 isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), 46 isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array() 47 ); 46 48 47 // get default configuration 48 $this->defaultConfig = array(); 49 $defaultConfigFile = sfConfig::get('sf_app_config_dir').'/'.basename($configFile); 50 if (is_readable($defaultConfigFile)) 51 { 52 $categories = array('required_categories' => array('default')); 53 $this->initialize($categories); 49 unset($myConfig['default']); 54 50 55 $this->defaultConfig = $this->parseYaml($defaultConfigFile); 56 } 51 $this->yamlConfig = $myConfig; 57 52 58 53 // iterate through all action names … … 70 65 if ($this->getConfigValue('activate', $actionName)) 71 66 { 72 $data[] = $this->addCache($actionName , $param);67 $data[] = $this->addCache($actionName); 73 68 } 74 69 … … 82 77 { 83 78 $data[] = ($first ? '' : "else\n{")."\n"; 84 $data[] = $this->addCache('DEFAULT' , $param);79 $data[] = $this->addCache('DEFAULT'); 85 80 $data[] = ($first ? '' : "}")."\n"; 86 81 } … … 95 90 } 96 91 97 private function addCache($actionName = '' , $param = array())92 private function addCache($actionName = '') 98 93 { 99 94 $data = array(); … … 116 111 117 112 // add cache information to cache manager 118 $data[] = sprintf(" \$this->cacheManager->addCache( '%s', '%s', '%s', %s, '%s', %s);\n\n",119 $ param['moduleName'], $actionName, $type, $lifeTime, $clientLifetime, var_export($vary, true));113 $data[] = sprintf(" \$this->cacheManager->addCache(\$context->getModuleName(), '%s', '%s', %s, '%s', %s);\n\n", 114 $actionName, $type, $lifeTime, $clientLifetime, var_export($vary, true)); 120 115 121 116 return implode("\n", $data); trunk/lib/config/sfCompileConfigHandler.class.php
r649 r843 32 32 * @throws sfParseException If a requested configuration file is improperly formatted. 33 33 */ 34 public function execute($configFile , $param = array())34 public function execute($configFiles) 35 35 { 36 if (!is_readable($configFile))37 {38 // can't read the configuration39 $error = sprintf('Configuration file "%s" does not exist or is not readable', $configFile);40 throw new sfConfigurationException($error);41 }42 43 36 // parse the yaml 44 $config = $this->parseYaml ($configFile);37 $config = $this->parseYamls($configFiles); 45 38 46 39 // init our data trunk/lib/config/sfConfigCache.class.php
r715 r843 43 43 * 44 44 * @param string The handler to use when parsing a configuration file. 45 * @param string An absolute filesystem path to a configuration file.45 * @param array An array of absolute filesystem paths to configuration files. 46 46 * @param string An absolute filesystem path to the cache file that will be written. 47 47 * … … 51 51 * does not have an associated configuration handler. 52 52 */ 53 private function callHandler($handler, $config , $cache, $param = array())53 private function callHandler($handler, $configs, $cache) 54 54 { 55 55 if (count($this->handlers) == 0) … … 58 58 $this->loadConfigHandlers(); 59 59 } 60 61 // handler to call for this configuration file 62 $handlerToCall = null; 60 63 61 64 // grab the base name of the handler … … 64 67 { 65 68 // we have a handler associated with the full configuration path 66 67 // call the handler and retrieve the cache data 68 $data = $this->handlers[$handler]->execute($config, $param); 69 70 $this->writeCacheFile($config, $cache, $data); 71 72 return; 69 $handlerToCall = $this->handlers[$handler]; 73 70 } 74 71 else if (isset($this->handlers[$basename])) 75 72 { 76 73 // we have a handler associated with the configuration base name 77 78 // call the handler and retrieve the cache data 79 $data = $this->handlers[$basename]->execute($config, $param); 80 $this->writeCacheFile($config, $cache, $data); 81 82 return; 74 $handlerToCall = $this->handlers[$basename]; 83 75 } 84 76 else … … 89 81 { 90 82 // replace wildcard chars in the configuration 91 $pattern = strtr($key, array('.' => '\.', 92 '*' => '.*?')); 83 $pattern = strtr($key, array('.' => '\.', '*' => '.*?')); 93 84 94 85 // create pattern from config … … 96 87 { 97 88 // we found a match! 98 99 // call the handler and retrieve the cache data 100 $data = $this->handlers[$key]->execute($config, $param); 101 102 $this->writeCacheFile($config, $cache, $data); 103 104 return; 89 $handlerToCall = $this->handlers[$key]; 90 91 break; 105 92 } 106 93 } 107 94 } 108 95 109 // we do not have a registered handler for this file 110 $error = sprintf('Configuration file "%s" does not have a registered handler', $config); 111 throw new sfConfigurationException($error); 96 if ($handlerToCall) 97 { 98 // call the handler and retrieve the cache data 99 $data = $handlerToCall->execute($configs); 100 101 $this->writeCacheFile($handler, $cache, $data); 102 } 103 else 104 { 105 // we do not have a registered handler for this file 106 $error = sprintf('Configuration file "%s" does not have a registered handler', $config); 107 108 throw new sfConfigurationException($error); 109 } 110 } 111 112 public function findConfigPaths($configPath) 113 { 114 $configs = array(); 115 116 $files = array( 117 sfConfig::get('sf_symfony_data_dir').'/config/'.basename($configPath), // default symfony configuration 118 sfConfig::get('sf_app_dir').'/config/'.basename($configPath), // default project configuration 119 sfConfig::get('sf_plugin_data_dir').'/'.$configPath, // used for plugin modules 120 sfConfig::get('sf_root_dir').'/'.$configPath, // used for main configuration 121 sfConfig::get('sf_cache_dir').'/'.$configPath, // used for generated modules 122 sfConfig::get('sf_app_dir').'/'.$configPath, 123 ); 124 125 foreach ($files as $file) 126 { 127 if (is_readable($file)) 128 { 129 $configs[] = $file; 130 } 131 } 132 133 return $configs; 112 134 } 113 135 … … 125 147 * @throws <b>sfConfigurationException</b> If a requested configuration file does not exist. 126 148 */ 127 public function checkConfig($configPath, $param = array()) 128 { 129 // full filename path to the config 130 $filename = $configPath; 131 132 if (!sfToolkit::isPathAbsolute($filename)) 133 { 134 // application configuration file 135 $filename = sfConfig::get('sf_app_dir').'/'.$filename; 136 137 if (!is_readable($filename)) 138 { 139 // project configuration file 140 $filename = sfConfig::get('sf_config_dir').'/'.basename($filename); 141 142 if (!is_readable($filename)) 143 { 144 // symfony configuration file 145 $filename = sfConfig::get('sf_symfony_data_dir').'/config/'.basename($filename); 146 } 147 } 148 } 149 150 if (!is_readable($filename)) 151 { 152 // configuration file does not exist 153 $error = sprintf('Configuration file "%s" does not exist or is unreadable', $configPath); 154 throw new sfConfigurationException($error); 155 } 156 149 public function checkConfig($configPath, $optional = false) 150 { 157 151 // the cache filename we'll be using 158 152 $cache = $this->getCacheName($configPath); 159 153 160 if (!is_readable($cache) || filemtime($filename) > filemtime($cache)) 161 { 162 // configuration file has changed so we need to reparse it 163 $this->callHandler($configPath, $filename, $cache, $param); 154 if (sfConfig::get('sf_in_bootstrap') && is_readable($cache)) 155 { 156 return $cache; 157 } 158 159 if (!sfToolkit::isPathAbsolute($configPath)) 160 { 161 $files = $this->findConfigPaths($configPath); 162 } 163 else 164 { 165 $files = is_readable($configPath) ? array($configPath) : array(); 166 } 167 168 if (!isset($files[0])) 169 { 170 if ($optional) 171 { 172 return null; 173 } 174 175 // configuration does not exist 176 $error = sprintf('Configuration "%s" does not exist or is unreadable', $configPath); 177 178 throw new sfConfigurationException($error); 179 } 180 181 // find the more recent configuration file last modification time 182 $mtime = 0; 183 foreach ($files as $file) 184 { 185 if (filemtime($file) > $mtime) 186 { 187 $mtime = filemtime($file); 188 } 189 } 190 191 if (!is_readable($cache) || $mtime > filemtime($cache)) 192 { 193 // configuration has changed so we need to reparse it 194 $this->callHandler($configPath, $files, $cache); 164 195 } 165 196 … … 210 241 * @return void 211 242 */ 212 public function import($config, $once = true, $ param = array())213 { 214 // check the config file215 $cache = $this->getCacheName($config); 216 if ( !sfConfig::get('sf_in_bootstrap') || !is_readable($cache))217 { 218 $cache = $this->checkConfig($config, $param);243 public function import($config, $once = true, $optional = false) 244 { 245 $cache = $this->checkConfig($config, $optional); 246 247 if ($optional && !$cache) 248 { 249 return; 219 250 } 220 251 … … 310 341 { 311 342 // cannot write cache file 312 $error = sprintf('Failed to write cache file "%s" generated from configuration file "%s"', 313 $cache, $config); 343 $error = sprintf('Failed to write cache file "%s" generated from configuration file "%s"', $cache, $config); 344 314 345 throw new sfCacheException($error); 315 346 } trunk/lib/config/sfConfigHandler.class.php
r500 r843 52 52 * improperly formatted. 53 53 */ 54 abstract function execute($configPath , $param = array());54 abstract function execute($configPath); 55 55 56 56 /** trunk/lib/config/sfDatabaseConfigHandler.class.php
r715 r843 34 34 * @throws sfParseException If a requested configuration file is improperly formatted. 35 35 */ 36 public function execute($configFile , $param = array())36 public function execute($configFiles) 37 37 { 38 $symfonyConfigFile = sfConfig::get('sf_symfony_data_dir').'/config/'.basename($configFile);39 $ projectConfigFile = sfConfig::get('sf_config_dir').'/'.basename($configFile);38 // parse the yaml 39 $myConfig = $this->parseYamls($configFiles); 40 40 41 if (!is_readable($configFile) && !is_readable($projectConfigFile)) 42 { 43 $error = sprintf('Configuration file "%s" or "%s" does not exist.', $configFile, $projectConfigFile); 44 throw new sfParseException($error); 45 } 46 47 $myConfig = $this->mergeConfigurations(sfConfig::get('sf_environment'), array( 48 array('default', $symfonyConfigFile), 49 array('default', $projectConfigFile), 50 array('all', $configFile), 51 )); 41 $myConfig = sfToolkit::arrayDeepMerge( 42 isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), 43 isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array(), 44 isset($myConfig[sfConfig::get('sf_environment')]) && is_array($myConfig[sfConfig::get('sf_environment')]) ? $myConfig[sfConfig::get('sf_environment')] : array() 45 ); 52 46 53 47 // init our data and includes arrays trunk/lib/config/sfDefineEnvironmentConfigHandler.class.php
r715 r843 28 28 * @throws sfParseException If a requested configuration file is improperly formatted. 29 29 */ 30 public function execute($configFile , $param = array())30 public function execute($configFiles) 31 31 { 32 32 // get our prefix 33 $prefix = $this->getParameterHolder()->get('prefix', '');33 $prefix = strtolower($this->getParameterHolder()->get('prefix', '')); 34 34 35 35 // add dynamic prefix if needed 36 if ( isset($param['prefix']))36 if ($this->getParameterHolder()->get('module', false)) 37 37 { 38 $prefix .= strtoupper($param['prefix']);38 $prefix .= "'.strtolower(\$moduleName).'_"; 39 39 } 40 40 41 $symfonyConfigFile = sfConfig::get('sf_symfony_data_dir').'/config/'.basename($configFile); 41 // parse the yaml 42 $myConfig = $this->parseYamls($configFiles); 42 43 43 $myConfig = $this->mergeConfigurations(sfConfig::get('sf_environment'), array( 44 array('default', $symfonyConfigFile), 45 array('all', $configFile), 46 )); 44 $myConfig = sfToolkit::arrayDeepMerge( 45 isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), 46 isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array(), 47 isset($myConfig[sfConfig::get('sf_environment')]) && is_array($myConfig[sfConfig::get('sf_environment')]) ? $myConfig[sfConfig::get('sf_environment')] : array() 48 ); 47 49 48 50 $values = array(); … … 50 52 { 51 53 $values = array_merge($values, $this->getValues($prefix, $category, $keys)); 54 } 55 56 $data = ''; 57 foreach ($values as $key => $value) 58 { 59 $data .= sprintf(" '%s' => %s,\n", $key, var_export($value, true)); 52 60 } 53 61 … … 58 66 $retval = "<?php\n". 59 67 "// auto-generated by sfDefineEnvironmentConfigHandler\n". 60 "// date: %s\nsfConfig::add( %s);\n?>";61 $retval = sprintf($retval, date('Y/m/d H:i:s'), var_export($values, true));68 "// date: %s\nsfConfig::add(array(\n%s));\n?>"; 69 $retval = sprintf($retval, date('Y/m/d H:i:s'), $data); 62 70 } 63 71 … … 69 77 if (!is_array($keys)) 70 78 { 71 list($key, $value) = $this->fixCategoryValue($prefix.$category, '', $keys); 79 list($key, $value) = $this->fixCategoryValue($prefix.strtolower($category), '', $keys); 80 72 81 return array($key => $value); 73 82 } … … 90 99 { 91 100 // prefix the key 92 $key = strtolower($category.$key);101 $key = $category.$key; 93 102 94 103 // replace constant values … … 110 119 } 111 120 112 return strtolower($category);121 return $category; 113 122 } 114 123 } trunk/lib/config/sfFactoryConfigHandler.class.php
r715 r843 32 32 * @throws <b>sfParseException</b> If a requested configuration file is improperly formatted. 33 33 */ 34 public function execute($configFile , $param = array())34 public function execute($configFiles) 35 35 { 36 $symfonyConfigFile = sfConfig::get('sf_symfony_data_dir').'/config/'.basename($configFile); 36 // parse the yaml 37 $myConfig = $this->parseYamls($configFiles); 37 38 38 $myConfig = $this->mergeConfigurations(sfConfig::get('sf_environment'), array( 39 array('default', $symfonyConfigFile), 40 array('all', $configFile), 41 )); 39 $myConfig = sfToolkit::arrayDeepMerge( 40 isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), 41 isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array(), 42 isset($myConfig[sfConfig::get('sf_environment')]) && is_array($myConfig[sfConfig::get('sf_environment')]) ? $myConfig[sfConfig::get('sf_environment')] : array() 43 ); 42 44 43 45 // init our data and includes arrays trunk/lib/config/sfFilterConfigHandler.class.php
r500 r843 31 31 * @throws sfParseException If a requested configuration file is improperly formatted. 32 32 */ 33 public function execute($configFile , $param = array())33 public function execute($configFiles) 34 34 { 35 35 // parse the yaml 36 $config = $this->parseYaml ($configFile);36 $config = $this->parseYamls($configFiles); 37 37 38 38 // init our data and includes arrays trunk/lib/config/sfGeneratorConfigHandler.class.php
r500 r843 30 30 * @throws sfInitializationException If a generator.yml key check fails. 31 31 */ 32 public function execute($configFile , $param = array())32 public function execute($configFiles) 33 33 { 34 34 // set our required categories list and initialize our handler … … 37 37 $this->initialize($categories); 38 38 39 // parse the ini40 $config = $this->parseYaml ($configFile);39 // parse the yaml 40 $config = $this->parseYamls($configFiles); 41 41 42 42 $config = $config['generator']; … … 56 56 $generator_manager->initialize(); 57 57 $generator_param = (isset($config['param']) ? $config['param'] : array()); 58 $param = array_merge($param, $generator_param); 59 $data = $generator_manager->generate($class, $param); 58 59 // hack to find the module name 60 preg_match('#'.sfConfig::get('sf_app_module_dir_name').'/([^/]+)/#', $configFiles[0], $match); 61 $generator_param['moduleName'] = $match[1]; 62 63 $data = $generator_manager->generate($class, $generator_param); 60 64 61 65 // compile data trunk/lib/config/sfPhpConfigHandler.class.php
r500 r843 30 30 * @throws <b>sfInitializationException</b> If a php.yml key check fails. 31 31 */ 32 public function execute($configFile , $param = array())32 public function execute($configFiles) 33 33 { 34 34 $this->initialize(); 35 35 36 36 // parse the yaml 37 $ config = $this->parseYaml($configFile);37 $myConfig = $this->parseYamls($configFiles); 38 38 39 39 // init our data array trunk/lib/config/sfRootConfigHandler.class.php
r500 r843 30 30 * @throws sfParseException If a requested configuration file is improperly formatted. 31 31 */ 32 public function execute($configFile , $param = array())32 public function execute($configFiles) 33 33 { 34 // parse the ini35 $config = $this->parseYaml ($configFile);34 // parse the yaml 35 $config = $this->parseYamls($configFiles); 36 36 37 37 // determine if we're loading the system config_handlers.yml or a module config_handlers.yml trunk/lib/config/sfRoutingConfigHandler.class.php
r500 r843 27 27 * @throws sfParseException If a requested configuration file is improperly formatted. 28 28 */ 29 public function execute($configFile , $param = array())29 public function execute($configFiles) 30 30 { 31 31 // parse the yaml 32 $config = $this->parseYaml ($configFile);32 $config = $this->parseYamls($configFiles); 33 33 34 34 // connect routes trunk/lib/config/sfSecurityConfigHandler.class.php
r718 r843 30 30 * @throws <b>sfInitializationException</b> If a view.yml key check fails. 31 31 */ 32 public function execute($configFile , $param = array())32 public function execute($configFiles) 33 33 { 34 34 // parse the yaml 35 $ this->yamlConfig = $this->parseYaml($configFile);35 $myConfig = $this->parseYamls($configFiles); 36 36 37 // get application configuration 38 $defaultConfigFile = sfConfig::get('sf_app_config_dir').'/'.basename($configFile); 39 $this->defaultConfig = is_readable($defaultConfigFile) ? $this->parseYaml($defaultConfigFile) : array(); 37 $myConfig['all'] = sfToolkit::arrayDeepMerge( 38 isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), 39 isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array() 40 ); 40 41 41 // iterate through all action names 42 $mergedConfig = array(); 43 foreach ($this->yamlConfig as $actionName => $values) 44 { 45 $mergedConfig[$actionName] = array( 46 'is_secure' => $this->getConfigValue('is_secure', $actionName), 47 'credentials' => $this->getConfigValue('credentials', $actionName), 48 ); 49 } 42 unset($myConfig['default']); 50 43 51 44 // compile data … … 53 46 "// auto-generated by sfSecurityConfigHandler\n". 54 47 "// date: %s\n\$this->security = %s\n?>", 55 date('Y/m/d H:i:s'), var_export($m ergedConfig, true));48 date('Y/m/d H:i:s'), var_export($myConfig, true)); 56 49 57 50 return $retval; trunk/lib/config/sfValidatorConfigHandler.class.php
r827 r843 31 31 * @throws sfParseException If a requested configuration file is improperly formatted. 32 32 */ 33 public function execute($configFile , $param = array())33 public function execute($configFiles) 34 34 { 35 35 // set our required categories list and initialize our handler … … 39 39 40 40 // parse the yaml 41 $config = $this->parseYaml ($configFile);41 $config = $this->parseYamls($configFiles); 42 42 43 43 // init our data, includes, methods, names and validators arrays trunk/lib/config/sfViewConfigHandler.class.php
r580 r843 30 30 * @throws <b>sfInitializationException</b> If a view.yml key check fails. 31 31 */ 32 public function execute($configFile , $param = array())32 public function execute($configFiles) 33 33 { 34 34 // set our required categories list and initialize our handler … … 37 37 38 38 // parse the yaml 39 $this->yamlConfig = $this->parseYaml($configFile); 39 $myConfig = $this->parseYamls($configFiles); 40 41 $myConfig['all'] = sfToolkit::arrayDeepMerge( 42 isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), 43 isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array() 44 ); 45 46 unset($myConfig['default']); 47 48 $this->yamlConfig = $myConfig; 40 49 41 50 // init our data array 42 51 $data = array(); 43 44 // get default configuration45 $this->defaultConfig = array();46 $defaultConfigFile = sfConfig::get('sf_app_config_dir').'/'.basename($configFile);47 if (is_readable($defaultConfigFile))48 {49 $categories = array('required_categories' => array('default'));50 $this->initialize($categories);51 52 $this->defaultConfig = $this->parseYaml($defaultConfigFile);53 }54 52 55 53 $data[] = "\$sf_safe_slot = sfConfig::get('sf_safe_slot');\n"; trunk/lib/config/sfYamlConfigHandler.class.php
r715 r843 21 21 { 22 22 protected 23 $yamlConfig = null, 24 $defaultConfig = null; 23 $yamlConfig = null; 24 25 protected function parseYamls($configFiles) 26 { 27 $config = array(); 28 foreach ($configFiles as $configFile) 29 { 30 $config = sfToolkit::arrayDeepMerge($config, $this->parseYaml($configFile)); 31 } 32 33 return $config; 34 } 25 35 26 36 /** … … 34 44 * @throws sfParseException If a requested configuration file is improperly formatted. 35 45 */ 36 protected function parseYaml($configFile , $param = array())46 protected function parseYaml($configFile) 37 47 { 38 48 if (!is_readable($configFile)) … … 40 50 // can't read the configuration 41 51 $error = sprintf('Configuration file "%s" does not exist or is not readable', $configFile); 52 42 53 throw new sfConfigurationException($error); 43 54 } … … 67 78 } 68 79 69 public function mergeConfigurations($environment, $files)70 {71 $configs = array();72 73 foreach ($files as $file)74 {75 if (is_readable($file[1]))76 {77 $config = $this->parseYaml($file[1]);78 79 if (isset($config[$file[0]]))80 {81 $configs[] = $config[$file[0]];82 }83 84 if (isset($config[$environment]) && is_array($config[$environment]))85 {86 $configs[] = $config[$environment];87 }88 }89 }90 91 if ($configs)92 {93 $config = call_user_func_array(array('sfToolkit', 'arrayDeepMerge'), $configs);94 95 return $config;96 }97 else98 {99 return array();100 }101 }102 103 80 protected function mergeConfigValue($keyName, $category) 104 81 { 105 82 $values = array(); 106 83 107 if (isset($this->defaultConfig['default'][$keyName]) && is_array($this->defaultConfig['default'][$keyName]))108 {109 $values = $this->defaultConfig['default'][$keyName];110 }111 112 84 if (isset($this->yamlConfig['all'][$keyName]) && is_array($this->yamlConfig['all'][$keyName])) 113 85 { 114 $values = array_merge($values, $this->yamlConfig['all'][$keyName]);86 $values = $this->yamlConfig['all'][$keyName]; 115 87 } 116 88 … … 133 105 return $this->yamlConfig['all'][$keyName]; 134 106 } 135 else if (isset($this->defaultConfig['default'][$keyName]))136 {137 return $this->defaultConfig['default'][$keyName];138 }139 107 140 108 return $defaultValue; trunk/lib/controller/sfController.class.php
r817 r843 147 147 { 148 148 // let's kill this party before it turns into cpu cycle hell 149 $error = 'Too many forwards have been detected for this request'; 149 $error = 'Too many forwards have been detected for this request (> %d)'; 150 $error = sprintf($error, $this->maxForwards); 150 151 151 152 throw new sfForwardException($error); … … 169 170 170 171 // check for a module generator config file 171 $sf_app_module_dir = sfConfig::get('sf_app_module_dir'); 172 $generatorConfig = $sf_app_module_dir.'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/generator.yml'; 173 if (is_readable($generatorConfig)) 174 { 175 sfConfigCache::getInstance()->import(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/generator.yml', true, array('moduleName' => $moduleName)); 176 } 172 sfConfigCache::getInstance()->import(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/generator.yml', true, true); 177 173 178 174 if (!$this->actionExists($moduleName, $actionName)) … … 206 202 207 203 // include module configuration 208 sfConfigCache::getInstance()->import('modules/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml', true, array('prefix' => $moduleName.'_'));204 require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml')); 209 205 210 206 // check if this module is internal … … 222 218 223 219 // check for a module config.php 224 $moduleConfig = $sf_app_module_dir.'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/config.php';220 $moduleConfig = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/config.php'; 225 221 if (is_readable($moduleConfig)) 226 222 { … … 307 303 if (sfConfig::get('sf_i18n')) 308 304 { 309 $this->context->getI18N()->setMessageSourceDir( $sf_app_module_dir.'/'.$moduleName.'/'.sfConfig::get('sf_app_module_i18n_dir_name'), $this->context->getUser()->getCulture());305 $this->context->getI18N()->setMessageSourceDir(sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_i18n_dir_name'), $this->context->getUser()->getCulture()); 310 306 } 311 307 trunk/lib/filter/sfCacheFilter.class.php
r714 r843 58 58 { 59 59 $actionName = $context->getActionName(); 60 require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$cacheConfigFile , array('moduleName' => $context->getModuleName())));60 require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$cacheConfigFile)); 61 61 }