Changeset 7811
- Timestamp:
- 03/12/08 01:55:10 (1 year ago)
- Files:
-
- branches/1.1/lib/config/sfAutoloadConfigHandler.class.php (modified) (5 diffs)
- branches/1.1/lib/config/sfCacheConfigHandler.class.php (modified) (2 diffs)
- branches/1.1/lib/config/sfCompileConfigHandler.class.php (modified) (3 diffs)
- branches/1.1/lib/config/sfConfigHandler.class.php (modified) (2 diffs)
- branches/1.1/lib/config/sfDatabaseConfigHandler.class.php (modified) (5 diffs)
- branches/1.1/lib/config/sfDefineEnvironmentConfigHandler.class.php (modified) (3 diffs)
- branches/1.1/lib/config/sfFactoryConfigHandler.class.php (modified) (7 diffs)
- branches/1.1/lib/config/sfFilterConfigHandler.class.php (modified) (4 diffs)
- branches/1.1/lib/config/sfGeneratorConfigHandler.class.php (modified) (2 diffs)
- branches/1.1/lib/config/sfRootConfigHandler.class.php (modified) (3 diffs)
- branches/1.1/lib/config/sfRoutingConfigHandler.class.php (modified) (2 diffs)
- branches/1.1/lib/config/sfSecurityConfigHandler.class.php (modified) (2 diffs)
- branches/1.1/lib/config/sfSimpleYamlConfigHandler.class.php (modified) (2 diffs)
- branches/1.1/lib/config/sfViewConfigHandler.class.php (modified) (5 diffs)
- branches/1.1/lib/config/sfYamlConfigHandler.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/config/sfAutoloadConfigHandler.class.php
r7792 r7811 33 33 { 34 34 // set our required categories list and initialize our handler 35 $categories = array('required_categories' => array('autoload')); 36 37 $this->initialize($categories); 35 $this->initialize(array('required_categories' => array('autoload'))); 38 36 39 37 // parse the yaml 40 $ myConfig = $this->parseYamls($configFiles);38 $config = self::getConfiguration($configFiles); 41 39 42 40 // init our data array … … 44 42 45 43 // let's do our fancy work 46 foreach ($ myConfig['autoload'] as $name => $entry)44 foreach ($config['autoload'] as $name => $entry) 47 45 { 48 46 if (isset($entry['name'])) … … 57 55 foreach ($entry['files'] as $class => $path) 58 56 { 59 $path = $this->replaceConstants($path);60 61 57 $data[] = sprintf("'%s' => '%s',", $class, $path); 62 58 } … … 67 63 $ext = isset($entry['ext']) ? $entry['ext'] : '.php'; 68 64 $path = $entry['path']; 69 70 $path = $this->replaceConstants($path);71 $path = $this->replacePath($path);72 65 73 66 // we automatically add our php classes … … 128 121 return $retval; 129 122 } 123 124 /** 125 * @see sfConfigHandler 126 */ 127 static public function getConfiguration(array $configFiles) 128 { 129 $config = self::replaceConstants(self::parseYamls($configFiles)); 130 131 foreach ($config['autoload'] as $name => $values) 132 { 133 if (isset($values['path'])) 134 { 135 $config['autoload'][$name]['path'] = self::replacePath($values['path']); 136 } 137 } 138 139 return $config; 140 } 130 141 } branches/1.1/lib/config/sfCacheConfigHandler.class.php
r6458 r7811 36 36 { 37 37 // parse the yaml 38 $myConfig = $this->parseYamls($configFiles); 39 40 $myConfig['all'] = sfToolkit::arrayDeepMerge( 41 isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), 42 isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array() 43 ); 44 45 unset($myConfig['default']); 46 47 $this->yamlConfig = $myConfig; 38 $this->yamlConfig = self::getConfiguration($configFiles); 48 39 49 40 // iterate through all action names … … 113 104 return implode("\n", $data); 114 105 } 106 107 /** 108 * @see sfConfigHandler 109 */ 110 static public function getConfiguration(array $configFiles) 111 { 112 return self::flattenConfiguration(self::parseYamls($configFiles)); 113 } 115 114 } branches/1.1/lib/config/sfCompileConfigHandler.class.php
r7792 r7811 35 35 { 36 36 // parse the yaml 37 $config = array(); 38 foreach ($configFiles as $configFile) 39 { 40 $config = array_merge($config, $this->parseYaml($configFile)); 41 } 37 $config = self::getConfiguration($configFiles); 42 38 43 39 // init our data … … 47 43 foreach ($config as $file) 48 44 { 49 $file = $this->replaceConstants($file);50 $file = $this->replacePath($file);51 52 45 if (!is_readable($file)) 53 46 { … … 110 103 return $config; 111 104 } 105 106 /** 107 * @see sfConfigHandler 108 */ 109 static public function getConfiguration(array $configFiles) 110 { 111 $config = array(); 112 foreach ($configFiles as $configFile) 113 { 114 $config = array_merge($config, self::parseYaml($configFile)); 115 } 116 117 return self::replacePath(self::replaceConstants($config)); 118 } 112 119 } branches/1.1/lib/config/sfConfigHandler.class.php
r7792 r7811 72 72 * @return string The new value 73 73 */ 74 public static function replaceConstants($value)74 static public function replaceConstants($value) 75 75 { 76 76 if (is_array($value)) … … 113 113 return $this->parameterHolder; 114 114 } 115 116 /** 117 * Returns the configuration for the current config handler. 118 * 119 * @param array An array of ordered configuration files 120 * 121 * @param array A configuration array 122 */ 123 static public function getConfiguration(array $configFiles) 124 { 125 throw new LogicException('You must call the ::getConfiguration() method on a concrete config handler class'); 126 } 115 127 } branches/1.1/lib/config/sfDatabaseConfigHandler.class.php
r7792 r7811 36 36 { 37 37 // parse the yaml 38 $myConfig = $this->parseYamls($configFiles); 39 40 $myConfig = sfToolkit::arrayDeepMerge( 41 isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), 42 isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array(), 43 isset($myConfig[sfConfig::get('sf_environment')]) && is_array($myConfig[sfConfig::get('sf_environment')]) ? $myConfig[sfConfig::get('sf_environment')] : array() 44 ); 38 $config = self::getConfiguration($configFiles); 45 39 46 40 // init our data and includes arrays … … 50 44 51 45 // get a list of database connections 52 foreach ($ myConfig as $name => $dbConfig)46 foreach ($config as $name => $dbConfig) 53 47 { 54 48 // is this category already registered? … … 72 66 { 73 67 // we have a file to include 74 $file = $this->replacePath($this->replaceConstants($dbConfig['file'])); 75 76 if (!is_readable($file)) 68 if (!is_readable($dbConfig['file'])) 77 69 { 78 70 // database file doesn't exist 79 throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $dbConfig['class'], $ file));71 throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $dbConfig['class'], $dbConfig['file'])); 80 72 } 81 73 82 74 // append our data 83 $includes[] = sprintf("require_once('%s');", $ file);75 $includes[] = sprintf("require_once('%s');", $dbConfig['file']); 84 76 } 85 77 … … 88 80 if (isset($dbConfig['param'])) 89 81 { 90 foreach ($dbConfig['param'] as $key => $value) 91 { 92 $parameters[$key] = $this->replaceConstants($value); 93 } 82 $parameters = $dbConfig['param']; 94 83 } 95 84 $parameters['name'] = $name; … … 105 94 date('Y/m/d H:i:s'), implode("\n", $includes), implode("\n", $data)); 106 95 } 96 97 /** 98 * @see sfConfigHandler 99 */ 100 static public function getConfiguration(array $configFiles) 101 { 102 $config = self::replaceConstants(self::flattenConfigurationWithEnvironment(self::parseYamls($configFiles))); 103 104 foreach ($config as $name => $dbConfig) 105 { 106 if (isset($dbConfig['file'])) 107 { 108 $config[$name]['file'] = $this->replacePath($dbConfig['file']); 109 } 110 } 111 112 return $config; 113 } 107 114 } branches/1.1/lib/config/sfDefineEnvironmentConfigHandler.class.php
r3254 r7811 40 40 41 41 // parse the yaml 42 $ myConfig = $this->mergeEnvironment($this->parseYamls($configFiles));42 $config = self::getConfiguration($configFiles); 43 43 44 44 $values = array(); 45 foreach ($ myConfig as $category => $keys)45 foreach ($config as $category => $keys) 46 46 { 47 47 $values = array_merge($values, $this->getValues($prefix, $category, $keys)); … … 110 110 protected function fixCategoryValue($category, $key, $value) 111 111 { 112 // prefix the key 113 $key = $category.$key; 114 115 // replace constant values 116 $value = $this->replaceConstants($value); 117 118 return array($key, $value); 112 return array($category.$key, $value); 119 113 } 120 114 … … 143 137 144 138 /** 145 * Merges default, all and current environment configurations. 146 * 147 * @param array The main configuratino array 148 * 149 * @param array The merged configuration 139 * @see sfConfigHandler 150 140 */ 151 protected function mergeEnvironment($config)141 static public function getConfiguration(array $configFiles) 152 142 { 153 return sfToolkit::arrayDeepMerge( 154 isset($config['default']) && is_array($config['default']) ? $config['default'] : array(), 155 isset($config['all']) && is_array($config['all']) ? $config['all'] : array(), 156 isset($config[sfConfig::get('sf_environment')]) && is_array($config[sfConfig::get('sf_environment')]) ? $config[sfConfig::get('sf_environment')] : array() 157 ); 143 return self::replaceConstants(self::flattenConfigurationWithEnvironment(self::parseYamls($configFiles))); 158 144 } 159 145 } branches/1.1/lib/config/sfFactoryConfigHandler.class.php
r7792 r7811 35 35 { 36 36 // parse the yaml 37 $myConfig = $this->parseYamls($configFiles); 38 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 ); 37 $config = self::getConfiguration($configFiles); 44 38 45 39 // init our data and includes arrays … … 54 48 { 55 49 // see if the factory exists for this controller 56 $keys = $ myConfig[$factory];50 $keys = $config[$factory]; 57 51 58 52 if (!isset($keys['class'])) … … 67 61 { 68 62 // we have a file to include 69 $file = $this->replaceConstants($keys['file']); 70 $file = $this->replacePath($file); 71 72 if (!is_readable($file)) 63 if (!is_readable($keys['file'])) 73 64 { 74 65 // factory file doesn't exist 75 throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $ file));66 throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $keys['file'])); 76 67 } 77 68 78 69 // append our data 79 $includes[] = sprintf("require_once('%s');", $ file);70 $includes[] = sprintf("require_once('%s');", $keys['file']); 80 71 } 81 72 … … 89 80 } 90 81 91 foreach ($keys['param'] as $key => $value) 92 { 93 $parameters[$key] = $this->replaceConstants($value); 94 } 82 $parameters = $keys['param']; 95 83 } 96 84 … … 180 168 foreach ($parameters['loggers'] as $name => $keys) 181 169 { 182 if (isset($keys['enabled']) && !$ this->replaceConstants($keys['enabled']))170 if (isset($keys['enabled']) && !$keys['enabled']) 183 171 { 184 172 continue; … … 194 182 if (isset($keys['param']['condition'])) 195 183 { 196 $condition = $ this->replaceConstants($keys['param']['condition']);184 $condition = $keys['param']['condition']; 197 185 unset($keys['param']['condition']); 198 186 } … … 228 216 return $retval; 229 217 } 218 219 /** 220 * @see sfConfigHandler 221 */ 222 static public function getConfiguration(array $configFiles) 223 { 224 $config = self::replaceConstants(self::flattenConfigurationWithEnvironment(self::parseYamls($configFiles))); 225 226 foreach ($config as $factory => $values) 227 { 228 if (isset($values['file'])) 229 { 230 $config[$factory]['file'] = $this->replacePath($values['file']); 231 } 232 } 233 234 return $config; 235 } 230 236 } branches/1.1/lib/config/sfFilterConfigHandler.class.php
r7792 r7811 34 34 { 35 35 // parse the yaml 36 $config = $this->parseYaml($configFiles[0]); 37 foreach (array_slice($configFiles, 1) as $i => $configFile) 38 { 39 // we get the order of the new file and merge with the previous configurations 40 $previous = $config; 41 42 $config = array(); 43 foreach ($this->parseYaml($configFile) as $key => $value) 44 { 45 $value = (array) $value; 46 $config[$key] = isset($previous[$key]) ? sfToolkit::arrayDeepMerge($previous[$key], $value) : $value; 47 } 48 49 // check that every key in previous array is still present (to avoid problem when upgrading) 50 foreach (array_keys($previous) as $key) 51 { 52 if (!isset($config[$key])) 53 { 54 throw new sfConfigurationException(sprintf('The filter name "%s" is defined in "%s" but not present in "%s" file. To disable a filter, add a "enabled" key with a false value.', $key, $configFiles[$i], $configFile)); 55 } 56 } 57 } 36 $config = self::getConfiguration($configFiles); 58 37 59 38 // init our data and includes arrays … … 82 61 if (isset($keys['file'])) 83 62 { 84 // we have a file to include 85 $file = $this->replaceConstants($keys['file']); 86 $file = $this->replacePath($file); 87 88 if (!is_readable($file)) 63 if (!is_readable($keys['file'])) 89 64 { 90 65 // filter file doesn't exist 91 throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $ file));66 throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $keys['file'])); 92 67 } 93 68 94 69 // append our data 95 $includes[] = sprintf("require_once('%s');\n", $ file);70 $includes[] = sprintf("require_once('%s');\n", $keys['file']); 96 71 } 97 72 … … 99 74 if (isset($keys['param']['condition'])) 100 75 { 101 $condition = $ this->replaceConstants($keys['param']['condition']);76 $condition = $keys['param']['condition']; 102 77 unset($keys['param']['condition']); 103 78 } … … 189 164 EOF; 190 165 } 166 167 /** 168 * @see sfConfigHandler 169 */ 170 static public function getConfiguration(array $configFiles) 171 { 172 $config = self::parseYaml($configFiles[0]); 173 foreach (array_slice($configFiles, 1) as $i => $configFile) 174 { 175 // we get the order of the new file and merge with the previous configurations 176 $previous = $config; 177 178 $config = array(); 179 foreach (self::parseYaml($configFile) as $key => $value) 180 { 181 $value = (array) $value; 182 $config[$key] = isset($previous[$key]) ? sfToolkit::arrayDeepMerge($previous[$key], $value) : $value; 183 } 184 185 // check that every key in previous array is still present (to avoid problem when upgrading) 186 foreach (array_keys($previous) as $key) 187 { 188 if (!isset($config[$key])) 189 { 190 throw new sfConfigurationException(sprintf('The filter name "%s" is defined in "%s" but not present in "%s" file. To disable a filter, add a "enabled" key with a false value.', $key, $configFiles[$i], $configFile)); 191 } 192 } 193 } 194 195 $config = self::replaceConstants($config); 196 197 foreach ($config as $category => $keys) 198 { 199 if (isset($keys['file'])) 200 { 201 $config['category']['file'] = $this->replacePath($keys['file']); 202 } 203 } 204 205 return $config; 206 } 191 207 } branches/1.1/lib/config/sfGeneratorConfigHandler.class.php
r7691 r7811 33 33 { 34 34 // parse the yaml 35 $config = $this->parseYamls($configFiles);35 $config = self::getConfiguration($configFiles); 36 36 if (!$config) 37 37 { … … 79 79 return $retval; 80 80 } 81 82 /** 83 * @see sfConfigHandler 84 */ 85 static public function getConfiguration(array $configFiles) 86 { 87 return self::parseYamls($configFiles); 88 } 81 89 } branches/1.1/lib/config/sfRootConfigHandler.class.php
r7509 r7811 33 33 { 34 34 // parse the yaml 35 $config = $this->parseYamls($configFiles);35 $config = self::getConfiguration($configFiles); 36 36 37 37 // determine if we're loading the system config_handlers.yml or a module config_handlers.yml … … 68 68 if (isset($keys['file'])) 69 69 { 70 // we have a file to include 71 $file = $this->replaceConstants($keys['file']); 72 $file = $this->replacePath($file); 73 74 if (!is_readable($file)) 70 if (!is_readable($keys['file'])) 75 71 { 76 72 // handler file doesn't exist 77 throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $ file));73 throw new sfParseException(sprintf('Configuration file "%s" specifies class "%s" with nonexistent or unreadable file "%s".', $configFiles[0], $class, $keys['file'])); 78 74 } 79 75 80 76 // append our data 81 $includes[] = sprintf("require_once('%s');", $ file);77 $includes[] = sprintf("require_once('%s');", $keys['file']); 82 78 } 83 79 … … 97 93 return $retval; 98 94 } 95 96 /** 97 * @see sfConfigHandler 98 */ 99 static public function getConfiguration(array $configFiles) 100 { 101 $config = self::replaceConstants(self::parseYamls($configFiles)); 102 103 foreach ($config as $category => $keys) 104 { 105 if (isset($keys['file'])) 106 { 107 $config['category']['file'] = $this->replacePath($keys['file']); 108 } 109 } 110 111 return $config; 112 } 99 113 } branches/1.1/lib/config/sfRoutingConfigHandler.class.php
r7616 r7811 30 30 { 31 31 // parse the yaml 32 $config = $this->parseYamls($configFiles);32 $config = self::getConfiguration($configFiles); 33 33 34 34 // connect routes … … 49 49 ); 50 50 } 51 52 /** 53 * @see sfConfigHandler 54 */ 55 static public function getConfiguration(array $configFiles) 56 { 57 return self::parseYamls($configFiles); 58 } 51 59 } branches/1.1/lib/config/sfSecurityConfigHandler.class.php
r3625 r7811 33 33 { 34 34 // parse the yaml 35 $myConfig = $this->parseYamls($configFiles); 36 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 ); 41 42 unset($myConfig['default']); 43 44 // change all of the keys to lowercase 45 $myConfig = array_change_key_case($myConfig); 35 $config = self::getConfiguration($configFiles); 46 36 47 37 // compile data … … 49 39 "// auto-generated by sfSecurityConfigHandler\n". 50 40 "// date: %s\n\$this->security = %s;\n", 51 date('Y/m/d H:i:s'), var_export($ myConfig, true));41 date('Y/m/d H:i:s'), var_export($config, true)); 52 42 53 43 return $retval; 54 44 } 45 46 /** 47 * @see sfConfigHandler 48 */ 49 static public function getConfiguration(array $configFiles) 50 { 51 $config = self::flattenConfiguration(self::parseYamls($configFiles)); 52 53 // change all of the keys to lowercase 54 $config = array_change_key_case($config); 55 56 return $config; 57 } 55 58 } branches/1.1/lib/config/sfSimpleYamlConfigHandler.class.php
r3203 r7811 28 28 public function execute($configFiles) 29 29 { 30 $config = $this->parseYamls($configFiles);30 $config = self::getConfiguration($configFiles); 31 31 32 32 // compile data … … 38 38 return $retval; 39 39 } 40 41 /** 42 * @see sfConfigHandler 43 */ 44 static public function getConfiguration(array $configFiles) 45 { 46 return self::parseYamls($configFiles); 47 } 40 48 } branches/1.1/lib/config/sfViewConfigHandler.class.php
r5214 r7811 32 32 public function execute($configFiles) 33 33 { 34 // set our required categories list and initialize our handler35 $categories = array('required_categories' => array());36 $this->initialize($categories);37 38 34 // parse the yaml 39 $this-> mergeConfig($this->parseYamls($configFiles));35 $this->yamlConfig = self::getConfiguration($configFiles); 40 36 41 37 // init our data array … … 108 104 109 105 return $retval; 110 }111 112 /**113 * Merges assets and environement configuration.114 *115 * @param array A configuration array116 */117 protected function mergeConfig($myConfig)118 {119 // merge javascripts and stylesheets120 $myConfig['all']['stylesheets'] = array_merge(isset($myConfig['default']['stylesheets']) && is_array($myConfig['default']['stylesheets']) ? $myConfig['default']['stylesheets'] : array(), isset($myConfig['all']['stylesheets']) && is_array($myConfig['all']['stylesheets']) ? $myConfig['all']['stylesheets'] : array());121 unset($myConfig['default']['stylesheets']);122 123 $myConfig['all']['javascripts'] = array_merge(isset($myConfig['default']['javascripts']) && is_array($myConfig['default']['javascripts']) ? $myConfig['default']['javascripts'] : array(), isset($myConfig['all']['javascripts']) && is_array($myConfig['all']['javascripts']) ? $myConfig['all']['javascripts'] : array());124 unset($myConfig['default']['javascripts']);125 126 // merge default and all127 $myConfig['all'] = sfToolkit::arrayDeepMerge(128 isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(),129 isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array()130 );131 132 unset($myConfig['default']);133 134 $this->yamlConfig = $myConfig;135 106 } 136 107 … … 268 239 } 269 240 270 $key = $this->replaceConstants($key);271 272 241 if ('-*' == $key) 273 242 { … … 311 280 } 312 281 313 $key = $this->replaceConstants($key);314 315 282 if ('-*' == $key) 316 283 { … … 352 319 return implode("\n", $data)."\n"; 353 320 } 321 322 /** 323 * @see sfConfigHandler 324 */ 325 static public function getConfiguration(array $configFiles) 326 { 327 return self::mergeConfig(self::parseYamls($configFiles)); 328 } 329 330 static protected function mergeConfig($config) 331 { 332 // merge javascripts and stylesheets 333 $config['all']['stylesheets'] = array_merge(isset($config['default']['stylesheets']) && is_array($config['default']['stylesheets']) ? $config['default']['stylesheets'] : array(), isset($config['all']['stylesheets']) && is_array($config['all']['stylesheets']) ? $config['all']['stylesheets'] : array()); 334 unset($config['default']['stylesheets']); 335 336 $config['all']['javascripts'] = array_merge(isset($config['default']['javascripts']) && is_array($config['default']['javascripts']) ? $config['default']['javascripts'] : array(), isset($config['all']['javascripts']) && is_array($config['all']['javascripts']) ? $config['all']['javascripts'] : array()); 337 unset($config['default']['javascripts']); 338 339 // merge default and all 340 $config['all'] = sfToolkit::arrayDeepMerge( 341 isset($config['default']) && is_array($config['default']) ? $config['default'] : array(), 342 isset($config['all']) && is_array($config['all']) ? $config['all'] : array() 343 ); 344 345 unset($config['default']); 346 347 return self::replaceConstants($config); 348 } 354 349 } branches/1.1/lib/config/sfYamlConfigHandler.class.php
r6456 r7811 30 30 * @return array A merged configuration array 31 31 */ 32 protectedfunction parseYamls($configFiles)32 static public function parseYamls($configFiles) 33 33 { 34 34 $config = array(); 35 35 foreach ($configFiles as $configFile) 36 36 { 37 $config = sfToolkit::arrayDeepMerge($config, $this->parseYaml($configFile));37 $config = sfToolkit::arrayDeepMerge($config, self::parseYaml($configFile)); 38 38 } 39 39 … … 51 51 * @throws sfParseException If a requested configuration file is improperly formatted 52 52 */ 53 protectedfunction parseYaml($configFile)53 static public function parseYaml($configFile) 54 54 { 55 55 if (!is_readable($configFile)) … … 118 118 return $defaultValue; 119 119 } 120 121 static public function flattenConfiguration($config) 122 { 123 $config['all'] = sfToolkit::arrayDeepMerge( 124 isset($config['default']) && is_array($config['default']) ? $config['default'] : array(), 125 isset($config['all']) && is_array($config['all']) ? $config['all'] : array() 126 ); 127 128 unset($config['default']); 129 130 return $config; 131 } 132 133 /** 134 * Merges default, all and current environment configurations. 135 * 136 * @param array The main configuratino array 137 * 138 * @param array The merged configuration 139 */ 140 static public function flattenConfigurationWithEnvironment($config) 141 { 142 return sfToolkit::arrayDeepMerge( 143 isset($config['default']) && is_array($config['default']) ? $config['default'] : array(), 144 isset($config['all']) && is_array($config['all']) ? $config['all'] : array(), 145 isset($config[sfConfig::get('sf_environment')]) && is_array($config[sfConfig::get('sf_environment')]) ? $config[sfConfig::get('sf_environment')] : array() 146 ); 147 } 120 148 }

