Development

Changeset 843

You must first sign up to be able to contribute.

Changeset 843

Show
Ignore:
Timestamp:
02/17/06 12:03:43 (2 years ago)
Author:
fabien
Message:

removed the cache cleaning process in debug mode
better config cache system (sith inheritance)
debug mode is now a lot faster
removed param parameter from config cache handler (not needed anymore)
configuration files can now be optionals
config handlers must now have config/ prefix for main configuration files
removed uneeded default configuration files

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/data/config/config_handlers.yml

    r665 r843  
    1 autoload.yml: 
     1config/autoload.yml: 
    22  class:    sfAutoloadConfigHandler 
    33 
    4 php.yml: 
     4config/php.yml: 
    55  class:    sfPhpConfigHandler 
    66 
    7 databases.yml: 
     7config/databases.yml: 
    88  class:    sfDatabaseConfigHandler 
    99 
    10 settings.yml: 
     10config/settings.yml: 
    1111  class:    sfDefineEnvironmentConfigHandler 
    1212  param: 
    1313    prefix: sf_ 
    1414 
    15 app.yml: 
     15config/app.yml: 
    1616  class:    sfDefineEnvironmentConfigHandler 
    1717  param: 
    1818    prefix: app_ 
    1919 
    20 factories.yml: 
     20config/factories.yml: 
    2121  class:    sfFactoryConfigHandler 
    2222 
    23 bootstrap_compile.yml: 
     23config/bootstrap_compile.yml: 
    2424  class:    sfCompileConfigHandler 
    2525 
    26 core_compile.yml: 
     26config/core_compile.yml: 
    2727  class:    sfCompileConfigHandler 
    2828 
    29 filters.yml: 
     29config/filters.yml: 
    3030  class:    sfFilterConfigHandler 
    3131 
    32 logging.yml: 
     32config/logging.yml: 
    3333  class:    sfDefineEnvironmentConfigHandler 
    3434  param: 
    3535    prefix: sf_logging_ 
     36 
     37config/routing.yml: 
     38  class:    sfRoutingConfigHandler 
     39 
     40config/i18n.yml: 
     41  class:    sfDefineEnvironmentConfigHandler 
     42  param: 
     43    prefix: sf_i18n_ 
    3644 
    3745modules/*/config/generator.yml: 
     
    4553  param: 
    4654    prefix: sf_mailer_ 
     55    module: yes 
    4756 
    4857modules/*/config/security.yml: 
     
    5968  param: 
    6069    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  
    5757 
    5858    // 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)); 
    6060 
    6161    return true; 
  • trunk/lib/config/sfAutoloadConfigHandler.class.php

    r717 r843  
    3030   * @throws sfParseException If a requested configuration file is improperly formatted. 
    3131   */ 
    32   public function execute($configFile, $param = array()
     32  public function execute($configFiles
    3333  { 
    3434    // set our required categories list and initialize our handler 
     
    3838 
    3939    // 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); 
    4841 
    4942    // init our data array 
  • trunk/lib/config/sfCacheConfigHandler.class.php

    r746 r843  
    3333   * @throws <b>sfInitializationException</b> If a cache.yml key check fails. 
    3434   */ 
    35   public function execute($configFile, $param = array()
     35  public function execute($configFiles
    3636  { 
    3737    // set our required categories list and initialize our handler 
     
    4040 
    4141    // parse the yaml 
    42     $this->yamlConfig = $this->parseYaml($configFile); 
     42    $myConfig = $this->parseYamls($configFiles); 
    4343 
    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    ); 
    4648 
    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']); 
    5450 
    55       $this->defaultConfig = $this->parseYaml($defaultConfigFile); 
    56     } 
     51    $this->yamlConfig = $myConfig; 
    5752 
    5853    // iterate through all action names 
     
    7065      if ($this->getConfigValue('activate', $actionName)) 
    7166      { 
    72         $data[] = $this->addCache($actionName, $param); 
     67        $data[] = $this->addCache($actionName); 
    7368      } 
    7469 
     
    8277    { 
    8378      $data[] = ($first ? '' : "else\n{")."\n"; 
    84       $data[] = $this->addCache('DEFAULT', $param); 
     79      $data[] = $this->addCache('DEFAULT'); 
    8580      $data[] = ($first ? '' : "}")."\n"; 
    8681    } 
     
    9590  } 
    9691 
    97   private function addCache($actionName = '', $param = array()
     92  private function addCache($actionName = ''
    9893  { 
    9994    $data = array(); 
     
    116111 
    117112    // 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)); 
    120115 
    121116    return implode("\n", $data); 
  • trunk/lib/config/sfCompileConfigHandler.class.php

    r649 r843  
    3232   * @throws sfParseException If a requested configuration file is improperly formatted. 
    3333   */ 
    34   public function execute($configFile, $param = array()
     34  public function execute($configFiles
    3535  { 
    36     if (!is_readable($configFile)) 
    37     { 
    38       // can't read the configuration 
    39       $error = sprintf('Configuration file "%s" does not exist or is not readable', $configFile); 
    40       throw new sfConfigurationException($error); 
    41     } 
    42  
    4336    // parse the yaml 
    44     $config = $this->parseYaml($configFile); 
     37    $config = $this->parseYamls($configFiles); 
    4538 
    4639    // init our data 
  • trunk/lib/config/sfConfigCache.class.php

    r715 r843  
    4343   * 
    4444   * @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
    4646   * @param string An absolute filesystem path to the cache file that will be written. 
    4747   * 
     
    5151   *                                       does not have an associated configuration handler. 
    5252   */ 
    53   private function callHandler($handler, $config, $cache, $param = array()
     53  private function callHandler($handler, $configs, $cache
    5454  { 
    5555    if (count($this->handlers) == 0) 
     
    5858      $this->loadConfigHandlers(); 
    5959    } 
     60 
     61    // handler to call for this configuration file 
     62    $handlerToCall = null; 
    6063 
    6164    // grab the base name of the handler 
     
    6467    { 
    6568      // 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]; 
    7370    } 
    7471    else if (isset($this->handlers[$basename])) 
    7572    { 
    7673      // 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]; 
    8375    } 
    8476    else 
     
    8981      { 
    9082        // replace wildcard chars in the configuration 
    91         $pattern = strtr($key, array('.' => '\.', 
    92                                      '*' => '.*?')); 
     83        $pattern = strtr($key, array('.' => '\.', '*' => '.*?')); 
    9384 
    9485        // create pattern from config 
     
    9687        { 
    9788          // 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; 
    10592        } 
    10693      } 
    10794    } 
    10895 
    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; 
    112134  } 
    113135 
     
    125147   * @throws <b>sfConfigurationException</b> If a requested configuration file does not exist. 
    126148   */ 
    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  { 
    157151    // the cache filename we'll be using 
    158152    $cache = $this->getCacheName($configPath); 
    159153 
    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); 
    164195    } 
    165196 
     
    210241   * @return void 
    211242   */ 
    212   public function import($config, $once = true, $param = array()
    213   { 
    214     // check the config file 
    215     $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
    219250    } 
    220251 
     
    310341    { 
    311342      // 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 
    314345      throw new sfCacheException($error); 
    315346    } 
  • trunk/lib/config/sfConfigHandler.class.php

    r500 r843  
    5252   *                               improperly formatted. 
    5353   */ 
    54   abstract function execute($configPath, $param = array()); 
     54  abstract function execute($configPath); 
    5555 
    5656  /** 
  • trunk/lib/config/sfDatabaseConfigHandler.class.php

    r715 r843  
    3434   * @throws sfParseException If a requested configuration file is improperly formatted. 
    3535   */ 
    36   public function execute($configFile, $param = array()
     36  public function execute($configFiles
    3737  { 
    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); 
    4040 
    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    ); 
    5246 
    5347    // init our data and includes arrays 
  • trunk/lib/config/sfDefineEnvironmentConfigHandler.class.php

    r715 r843  
    2828   * @throws sfParseException If a requested configuration file is improperly formatted. 
    2929   */ 
    30   public function execute($configFile, $param = array()
     30  public function execute($configFiles
    3131  { 
    3232    // get our prefix 
    33     $prefix = $this->getParameterHolder()->get('prefix', ''); 
     33    $prefix = strtolower($this->getParameterHolder()->get('prefix', '')); 
    3434 
    3535    // add dynamic prefix if needed 
    36     if (isset($param['prefix'])) 
     36    if ($this->getParameterHolder()->get('module', false)) 
    3737    { 
    38       $prefix .= strtoupper($param['prefix'])
     38      $prefix .= "'.strtolower(\$moduleName).'_"
    3939    } 
    4040 
    41     $symfonyConfigFile = sfConfig::get('sf_symfony_data_dir').'/config/'.basename($configFile); 
     41    // parse the yaml 
     42    $myConfig = $this->parseYamls($configFiles); 
    4243 
    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    ); 
    4749 
    4850    $values = array(); 
     
    5052    { 
    5153      $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)); 
    5260    } 
    5361 
     
    5866      $retval = "<?php\n". 
    5967                "// 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); 
    6270    } 
    6371 
     
    6977    if (!is_array($keys)) 
    7078    { 
    71       list($key, $value) = $this->fixCategoryValue($prefix.$category, '', $keys); 
     79      list($key, $value) = $this->fixCategoryValue($prefix.strtolower($category), '', $keys); 
     80 
    7281      return array($key => $value); 
    7382    } 
     
    9099  { 
    91100    // prefix the key 
    92     $key = strtolower($category.$key)
     101    $key = $category.$key
    93102 
    94103    // replace constant values 
     
    110119    } 
    111120 
    112     return strtolower($category)
     121    return $category
    113122  } 
    114123} 
  • trunk/lib/config/sfFactoryConfigHandler.class.php

    r715 r843  
    3232   * @throws <b>sfParseException</b> If a requested configuration file is improperly formatted. 
    3333   */ 
    34   public function execute($configFile, $param = array()
     34  public function execute($configFiles
    3535  { 
    36     $symfonyConfigFile = sfConfig::get('sf_symfony_data_dir').'/config/'.basename($configFile); 
     36    // parse the yaml 
     37    $myConfig = $this->parseYamls($configFiles); 
    3738 
    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    ); 
    4244 
    4345    // init our data and includes arrays 
  • trunk/lib/config/sfFilterConfigHandler.class.php

    r500 r843  
    3131   * @throws sfParseException If a requested configuration file is improperly formatted. 
    3232   */ 
    33   public function execute($configFile, $param = array()
     33  public function execute($configFiles
    3434  { 
    3535    // parse the yaml 
    36     $config = $this->parseYaml($configFile); 
     36    $config = $this->parseYamls($configFiles); 
    3737 
    3838    // init our data and includes arrays 
  • trunk/lib/config/sfGeneratorConfigHandler.class.php

    r500 r843  
    3030   * @throws sfInitializationException If a generator.yml key check fails. 
    3131   */ 
    32   public function execute($configFile, $param = array()
     32  public function execute($configFiles
    3333  { 
    3434    // set our required categories list and initialize our handler 
     
    3737    $this->initialize($categories); 
    3838 
    39     // parse the ini 
    40     $config = $this->parseYaml($configFile); 
     39    // parse the yaml 
     40    $config = $this->parseYamls($configFiles); 
    4141 
    4242    $config = $config['generator']; 
     
    5656    $generator_manager->initialize(); 
    5757    $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); 
    6064 
    6165    // compile data 
  • trunk/lib/config/sfPhpConfigHandler.class.php

    r500 r843  
    3030   * @throws <b>sfInitializationException</b> If a php.yml key check fails. 
    3131   */ 
    32   public function execute($configFile, $param = array()
     32  public function execute($configFiles
    3333  { 
    3434    $this->initialize(); 
    3535 
    3636    // parse the yaml 
    37     $config = $this->parseYaml($configFile); 
     37    $myConfig = $this->parseYamls($configFiles); 
    3838 
    3939    // init our data array 
  • trunk/lib/config/sfRootConfigHandler.class.php

    r500 r843  
    3030   * @throws sfParseException If a requested configuration file is improperly formatted. 
    3131   */ 
    32   public function execute($configFile, $param = array()
     32  public function execute($configFiles
    3333  { 
    34     // parse the ini 
    35     $config = $this->parseYaml($configFile); 
     34    // parse the yaml 
     35    $config = $this->parseYamls($configFiles); 
    3636 
    3737    // determine if we're loading the system config_handlers.yml or a module config_handlers.yml 
  • trunk/lib/config/sfRoutingConfigHandler.class.php

    r500 r843  
    2727   * @throws sfParseException If a requested configuration file is improperly formatted. 
    2828   */ 
    29   public function execute($configFile, $param = array()
     29  public function execute($configFiles
    3030  { 
    3131    // parse the yaml 
    32     $config = $this->parseYaml($configFile); 
     32    $config = $this->parseYamls($configFiles); 
    3333 
    3434    // connect routes 
  • trunk/lib/config/sfSecurityConfigHandler.class.php

    r718 r843  
    3030   * @throws <b>sfInitializationException</b> If a view.yml key check fails. 
    3131   */ 
    32   public function execute($configFile, $param = array()
     32  public function execute($configFiles
    3333  { 
    3434    // parse the yaml 
    35     $this->yamlConfig = $this->parseYaml($configFile); 
     35    $myConfig = $this->parseYamls($configFiles); 
    3636 
    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    ); 
    4041 
    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']); 
    5043 
    5144    // compile data 
     
    5346                      "// auto-generated by sfSecurityConfigHandler\n". 
    5447                      "// date: %s\n\$this->security = %s\n?>", 
    55                       date('Y/m/d H:i:s'), var_export($mergedConfig, true)); 
     48                      date('Y/m/d H:i:s'), var_export($myConfig, true)); 
    5649 
    5750    return $retval; 
  • trunk/lib/config/sfValidatorConfigHandler.class.php

    r827 r843  
    3131   * @throws sfParseException If a requested configuration file is improperly formatted. 
    3232   */ 
    33   public function execute($configFile, $param = array()
     33  public function execute($configFiles
    3434  { 
    3535    // set our required categories list and initialize our handler 
     
    3939 
    4040    // parse the yaml 
    41     $config = $this->parseYaml($configFile); 
     41    $config = $this->parseYamls($configFiles); 
    4242 
    4343    // init our data, includes, methods, names and validators arrays 
  • trunk/lib/config/sfViewConfigHandler.class.php

    r580 r843  
    3030   * @throws <b>sfInitializationException</b> If a view.yml key check fails. 
    3131   */ 
    32   public function execute($configFile, $param = array()
     32  public function execute($configFiles
    3333  { 
    3434    // set our required categories list and initialize our handler 
     
    3737 
    3838    // 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; 
    4049 
    4150    // init our data array 
    4251    $data = array(); 
    43  
    44     // get default configuration 
    45     $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     } 
    5452 
    5553    $data[] = "\$sf_safe_slot = sfConfig::get('sf_safe_slot');\n"; 
  • trunk/lib/config/sfYamlConfigHandler.class.php

    r715 r843  
    2121{ 
    2222  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  } 
    2535 
    2636  /** 
     
    3444   * @throws sfParseException If a requested configuration file is improperly formatted. 
    3545   */ 
    36   protected function parseYaml($configFile, $param = array()
     46  protected function parseYaml($configFile
    3747  { 
    3848    if (!is_readable($configFile)) 
     
    4050      // can't read the configuration 
    4151      $error = sprintf('Configuration file "%s" does not exist or is not readable', $configFile); 
     52 
    4253      throw new sfConfigurationException($error); 
    4354    } 
     
    6778  } 
    6879 
    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     else 
    98     { 
    99       return array(); 
    100     } 
    101   } 
    102  
    10380  protected function mergeConfigValue($keyName, $category) 
    10481  { 
    10582    $values = array(); 
    10683 
    107     if (isset($this->defaultConfig['default'][$keyName]) && is_array($this->defaultConfig['default'][$keyName])) 
    108     { 
    109       $values = $this->defaultConfig['default'][$keyName]; 
    110     } 
    111  
    11284    if (isset($this->yamlConfig['all'][$keyName]) && is_array($this->yamlConfig['all'][$keyName])) 
    11385    { 
    114       $values = array_merge($values, $this->yamlConfig['all'][$keyName])
     86      $values = $this->yamlConfig['all'][$keyName]
    11587    } 
    11688 
     
    133105      return $this->yamlConfig['all'][$keyName]; 
    134106    } 
    135     else if (isset($this->defaultConfig['default'][$keyName])) 
    136     { 
    137       return $this->defaultConfig['default'][$keyName]; 
    138     } 
    139107 
    140108    return $defaultValue; 
  • trunk/lib/controller/sfController.class.php

    r817 r843  
    147147    { 
    148148      // 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); 
    150151 
    151152      throw new sfForwardException($error); 
     
    169170 
    170171    // 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); 
    177173 
    178174    if (!$this->actionExists($moduleName, $actionName)) 
     
    206202 
    207203    // 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')); 
    209205 
    210206    // check if this module is internal 
     
    222218 
    223219      // 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'; 
    225221      if (is_readable($moduleConfig)) 
    226222      { 
     
    307303        if (sfConfig::get('sf_i18n')) 
    308304        { 
    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()); 
    310306        } 
    311307 
  • trunk/lib/filter/sfCacheFilter.class.php

    r714 r843  
    5858      { 
    5959        $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)); 
    6161      }