Development

Changeset 7614

You must first sign up to be able to contribute.

Changeset 7614

Show
Ignore:
Timestamp:
02/26/08 18:38:26 (1 year ago)
Author:
fabien
Message:

added a new configuration system

  • added a new sfProjectConfiguration and sfApplicationConfiguration classes
  • all config.php file are gone and replaced with ProjectConfiguration? and #APP_NAME#Configuration classes
  • sfCore has been removed
  • sfLoader static methods have been moved to sfProjectConfiguration and sfApplicationConfiguration
  • sfI18N now takes a configuration object as its first argument
  • sfGeneratorManager now takes a configuration object as its first argument
  • sfConfigCache is not a singleton anymore
  • SF_* constants are gone
  • sfDatabaseManager now takes a configuration object as its first argument

Please read the UPGRADE file to upgrade your projects

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/UPGRADE

    r7518 r7614  
    1212To upgrade a project: 
    1313 
    14   * Upgrade symfony via PEAR or change your `config/config.php` 
    15     to update the symfony directory. 
     14  * If you don't use a SCM tool, please make a backup of your project. 
     15    As symfony replaces some files during the upgrade 
     16    (front controllers for example), you need a way to merge your 
     17    customizations after the upgrade. 
    1618 
    1719  * Update the `symfony` file located in the project root directory 
    18     by changing the line: 
    19  
     20    by changing those three lines: 
     21 
     22        [php] 
     23        chdir(dirname(__FILE__)); 
     24        include('config/config.php'); 
    2025        include($sf_symfony_data_dir.'/bin/symfony.php'); 
    2126 
    2227    to 
    2328 
    24         include($sf_symfony_lib_dir.'/command/cli.php'); 
     29        [php] 
     30        chdir(dirname(__FILE__)); 
     31        require_once(dirname(__FILE__).'/lib/ProjectConfiguration.class.php'); 
     32        $configuration = new ProjectConfiguration(); 
     33        include($configuration->getSymfonyLibDir().'/command/cli.php'); 
     34 
     35    You can also copy the skeleton file from the symfony project skeleton directly: 
     36 
     37        $ cp /path/to/symfony/lib/task/generator/skeleton/project/symfony symfony 
     38 
     39  * Create a `lib/ProjectConfiguration.class.php` file with the following content: 
     40 
     41        [php] 
     42        <?php 
     43 
     44        require_once '##SYMFONY_LIB_DIR##/autoload/sfCoreAutoload.class.php'; 
     45        sfCoreAutoload::register(); 
     46 
     47        class ProjectConfiguration extends sfProjectConfiguration 
     48        { 
     49          public function setup() 
     50          { 
     51          } 
     52        } 
     53 
     54    Then, replace `##SYMFONY_LIB_DIR##` with the path to the symfony 1.1 
     55    `lib/` directory. This is the new way to change the symfony version used 
     56    for your project. 
     57 
     58    You can also copy the skeleton file from the symfony project skeleton directly: 
     59 
     60        $ cp /path/to/symfony/lib/task/generator/skeleton/project/lib/ProjectConfiguration.class.php lib/ProjectConfiguration.class.php 
    2561 
    2662  * Launch the `project:upgrade1.1` task from your project directory 
     
    213249 
    214250The `autoloading_function` setting in `settings.yml` is not used anymore. 
    215 You can register autoloading callables in the application `config.php`. 
    216 Here is the new default `config.php`: 
    217  
    218     [php] 
    219     <?php 
    220      
    221     // include project configuration 
    222     include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    223      
    224     // symfony bootstraping 
    225     require_once($sf_symfony_lib_dir.'/util/sfCore.class.php'); 
    226     sfCore::bootstrap($sf_symfony_lib_dir, $sf_symfony_data_dir); 
    227      
    228     // insert your own autoloading callables here 
    229      
    230     if (sfConfig::get('sf_debug')) 
    231     { 
    232       spl_autoload_register(array('sfAutoload', 'autoloadAgain')); 
    233     } 
     251You can register autoloading callables in your application configuration class. 
    234252 
    235253Thanks to the new `sfAutoload::autoloadAgain()` method, you won't need to clear 
    236254the cache when you add or move classes in your project. This method will 
    237255automatically find the changes and flush the autoloading cache. 
    238  
    239 The `project:upgrade1.1` task makes all those changes for you. 
    240256 
    241257VERSION 
     
    466482 
    467483The symfony core has been upgraded to take these changes into account. 
     484 
     485sfLoader 
     486-------- 
     487 
     488All `sfLoader` static methods (except `::getHelperDirs()` and `::loadHelpers()`) 
     489have been moved to the `sfProjectConfiguration` and `sfApplicationConfiguration` 
     490classes: 
     491 
     492  * `sfProjectConfiguration`: 
     493      * `->getGeneratorSkeletonDirs()` 
     494      * `->getGeneratorTemplate()` 
     495      * `->getGeneratorTemplateDirs()` 
     496      * `->getModelDirs()` 
     497 
     498  * `sfApplicationConfiguration`: 
     499      * `->getControllerDirs()` 
     500      * `->getTemplateDirs()` 
     501      * `->getTemplateDir()` 
     502      * `->getTemplatePath()` 
     503      * `->getI18NGlobalDirs()` 
     504      * `->getI18NDirs()` 
     505      * `->getConfigPaths()` 
     506 
     507sfCore 
     508------ 
     509 
     510The `sfCore` has been removed. The code has been moved to `sfProjectConfiguration`, 
     511`sfApplicationConfiguration`, and `sfContext` classes. 
     512 
     513Front Controllers 
     514----------------- 
     515 
     516All front controllers have to be upgraded. The SF_DEBUG, SF_APP, SF_ENVIRONMENT, 
     517and SF_ROOT_DIR constants are gone. If you use some of these constants in your 
     518project, please use their sfConfig::get('') counterparts: 
     519 
     520 *Old*             | *New* 
     521 ----------------- | --------------------------------- 
     522 `SF_ROOT_DIR`     | `sfConfig::get('sf_root_dir')` 
     523 `SF_ENVIRONMENT`  | `sfConfig::get('sf_environment')` 
     524 `SF_APP`          | `sfConfig::get('sf_app')` 
     525 `SF_DEBUG`        | `sfConfig::get('sf_debug')` 
     526 
     527The `project:upgrade1.1` task upgrades all front controllers for you. 
     528If you made some customizations, symfony will issue a warning and won't 
     529upgrade them automatically. You can then copy the default skeleton from 
     530symfony: /path/to/symfony/lib/task/generator/skeleton/app/web/index.php 
     531 
     532config.php 
     533---------- 
     534 
     535All `config.php` files have been removed. The are replaced by the `ProjectConfiguration` 
     536class and the application configuration classes. 
     537 
     538If you've added some cutomizations in `config.php` files, you will have to migrate them 
     539to those new classes. 
  • branches/1.1/lib/action/sfAction.class.php

    r6668 r7614  
    3636 
    3737    // include security configuration 
    38     if($file = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$this->getModuleName().'/'.sfConfig::get('sf_app_module_config_dir_name').'/security.yml', true)) 
     38    if ($file = $context->getConfigCache()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$this->getModuleName().'/'.sfConfig::get('sf_app_module_config_dir_name').'/security.yml', true)) 
    3939    { 
    4040      require($file); 
  • branches/1.1/lib/autoload/sfAutoload.class.php

    r7247 r7614  
    8787  public function reloadClasses($force = false) 
    8888  { 
    89     if ($force) 
     89    $configuration = sfProjectConfiguration::getActive(); 
     90    if (!$configuration || !$configuration instanceof sfApplicationConfiguration) 
    9091    { 
    91       @unlink(sfConfigCache::getInstance()->getCacheName(sfConfig::get('sf_app_config_dir_name').'/autoload.yml'))
     92      return
    9293    } 
    9394 
    94     $file = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/autoload.yml'); 
     95    if ($force && file_exists($configuration->getConfigCache()->getCacheName('config/autoload.yml'))) 
     96    { 
     97      unlink($configuration->getConfigCache()->getCacheName('config/autoload.yml')); 
     98    } 
     99 
     100    $file = $configuration->getConfigCache()->checkConfig('config/autoload.yml'); 
    95101 
    96102    $this->classes = include($file); 
     
    125131  } 
    126132 
    127   function autoloadAgain($class) 
     133  public function autoloadAgain($class) 
    128134  { 
    129135    self::reloadClasses(true); 
  • branches/1.1/lib/autoload/sfCoreAutoload.class.php

    r7452 r7614  
    158158  'sfFormatter' => 'command', 
    159159  'sfSymfonyCommandApplication' => 'command', 
     160  'sfApplicationConfiguration' => 'config', 
    160161  'sfAutoloadConfigHandler' => 'config', 
    161162  'sfCacheConfigHandler' => 'config', 
     
    170171  'sfGeneratorConfigHandler' => 'config', 
    171172  'sfLoader' => 'config', 
     173  'sfProjectConfiguration' => 'config', 
    172174  'sfRootConfigHandler' => 'config', 
    173175  'sfRoutingConfigHandler' => 'config', 
     
    315317  'sfProjectUnfreezeTask' => 'task/project', 
    316318  'sfUpgradeTo11Task' => 'task/project', 
    317   'sfAutoloadingUpgrade' => 'task/project/upgrade1.1', 
    318319  'sfComponentUpgrade' => 'task/project/upgrade1.1', 
    319320  'sfConfigFileUpgrade' => 'task/project/upgrade1.1', 
     
    325326  'sfPropelUpgrade' => 'task/project/upgrade1.1', 
    326327  'sfSingletonUpgrade' => 'task/project/upgrade1.1', 
     328  'sfTestUpgrade' => 'task/project/upgrade1.1', 
    327329  'sfUpgrade' => 'task/project/upgrade1.1', 
    328330  'sfWebDebugUpgrade' => 'task/project/upgrade1.1', 
     
    341343  'sfCallable' => 'util', 
    342344  'sfContext' => 'util', 
    343   'sfCore' => 'util', 
    344345  'sfDomCssSelector' => 'util', 
    345346  'sfFinder' => 'util', 
  • branches/1.1/lib/command/sfSymfonyCommandApplication.class.php

    r7467 r7614  
    3131    } 
    3232 
    33     // initialize symfony core autoloading 
    34     require_once($this->options['symfony_lib_dir'].'/autoload/sfCoreAutoload.class.php'); 
    35     sfCoreAutoload::getInstance()->register(); 
     33    $configuration = new sfProjectConfiguration(getcwd()); 
    3634 
    3735    // application 
     
    3937    $this->setVersion(SYMFONY_VERSION); 
    4038 
    41     $this->initializeEnvironment($this->options['symfony_lib_dir']); 
    4239    $this->initializeTasks(); 
    4340  } 
     
    7471 
    7572  /** 
    76    * Initializes the environment variables and include path. 
    77    * 
    78    * @param string The symfony lib directory 
    79    */ 
    80   protected function initializeEnvironment($symfonyLibDir) 
    81   { 
    82     sfConfig::set('sf_symfony_lib_dir', $symfonyLibDir); 
    83  
    84     // directory layout 
    85     sfCore::initDirectoryLayout(getcwd()); 
    86  
    87     // include path 
    88     set_include_path( 
    89       sfConfig::get('sf_lib_dir').PATH_SEPARATOR. 
    90       sfConfig::get('sf_app_lib_dir').PATH_SEPARATOR. 
    91       sfConfig::get('sf_model_dir').PATH_SEPARATOR. 
    92       get_include_path() 
    93     ); 
    94   } 
    95  
    96   /** 
    9773   * Loads all available tasks. 
    9874   * 
     
    10278  { 
    10379    $dirs = array( 
    104       sfConfig::get('sf_symfony_lib_dir').'/task',                // symfony tasks 
    105       sfConfig::get('sf_symfony_lib_dir').'/plugins/*/lib/task', // bundled plugin tasks 
    106       sfConfig::get('sf_plugins_dir').'/*/lib/task',              // plugin tasks 
    107       sfConfig::get('sf_lib_dir').'/task',                        // project tasks 
     80      sfConfig::get('sf_symfony_lib_dir').'/task',               // symfony tasks 
     81      sfConfig::get('sf_symfony_lib_dir').'/plugins/*/lib/task', // bundled plugin tasks 
     82      sfConfig::get('sf_plugins_dir').'/*/lib/task',             // plugin tasks 
     83      sfConfig::get('sf_lib_dir').'/task',                       // project tasks 
    10884    ); 
    10985    $finder = sfFinder::type('file')->name('*Task.class.php'); 
     86 
    11087    foreach ($dirs as $globDir) 
    11188    { 
  • branches/1.1/lib/config/config/core_compile.yml

    r5320 r7614  
    44- %SF_SYMFONY_LIB_DIR%/action/sfActionStack.class.php 
    55- %SF_SYMFONY_LIB_DIR%/action/sfActionStackEntry.class.php 
    6 #- %SF_SYMFONY_LIB_DIR%/config/sfLoader.class.php 
    76- %SF_SYMFONY_LIB_DIR%/controller/sfController.class.php 
    87- %SF_SYMFONY_LIB_DIR%/database/sfDatabaseManager.class.php 
    9 - %SF_SYMFONY_LIB_DIR%/event/sfEvent.class.php 
    10 - %SF_SYMFONY_LIB_DIR%/event/sfEventDispatcher.class.php 
    118- %SF_SYMFONY_LIB_DIR%/filter/sfFilter.class.php 
    129- %SF_SYMFONY_LIB_DIR%/filter/sfCommonFilter.class.php 
     
    1815- %SF_SYMFONY_LIB_DIR%/storage/sfStorage.class.php 
    1916- %SF_SYMFONY_LIB_DIR%/user/sfUser.class.php 
    20 #- %SF_SYMFONY_LIB_DIR%/util/sfContext.class.php 
    21 #- %SF_SYMFONY_LIB_DIR%/validator/sfValidatorManager.class.php 
    22 #- %SF_SYMFONY_LIB_DIR%/util/sfParameterHolder.class.php 
    2317- %SF_SYMFONY_LIB_DIR%/view/sfView.class.php 
    2418 
    2519# these classes are optionals but very likely to be used (in web context) 
    26 #- %SF_SYMFONY_LIB_DIR%/controller/sfRouting.class.php 
    2720- %SF_SYMFONY_LIB_DIR%/controller/sfWebController.class.php 
    2821- %SF_SYMFONY_LIB_DIR%/controller/sfFrontWebController.class.php 
  • branches/1.1/lib/config/sfCompileConfigHandler.class.php

    r7370 r7614  
    6565 
    6666      // insert configuration files 
    67       $contents = preg_replace_callback(array('#(require|include)(_once)?\((sfConfigCache::getInstance\(\)|\$configCache)->checkConfig\([^_]+sf_app_config_dir_name[^\.]*\.\'/([^\']+)\'\)\);#m', 
    68                                           '#()()(sfConfigCache::getInstance\(\)|\$configCache)->import\(.sf_app_config_dir_name\.\'/([^\']+)\'(, false)?\);#m'), 
     67/*      $contents = preg_replace_callback(array('#(require|include)(_once)?\((sfContext::getInstance\(\)\->getConfigCache\(\)|\$configCache)->checkConfig\(\'config/([^\']+)\'\)\);#m', 
     68                                          '#()()(sfContext::getInstance\(\)\->getConfigCache\(\)|\$configCache)->import\(\'config/([^\']+)\'(, false)?\);#m'), 
    6969                                        array($this, 'insertConfigFileCallback'), $contents); 
    70  
     70*/ 
    7171      // strip php tags 
    7272      $contents = sfToolkit::pregtr($contents, array('/^\s*<\?(php)?/m' => '', 
     
    103103    $configFile = sfConfig::get('sf_app_config_dir_name').'/'.$matches[4]; 
    104104 
    105     sfConfigCache::getInstance()->checkConfig($configFile); 
     105    $configCache = sfContext::getInstance()->getConfigCache(); 
     106    $configCache->checkConfig($configFile); 
    106107 
    107     $config = "// '$configFile' config file\n". 
    108               file_get_contents(sfConfigCache::getInstance()->getCacheName($configFile)); 
     108    $config = "// '$configFile' config file\n".file_get_contents($configCache->getCacheName($configFile)); 
    109109 
    110110    return $config; 
  • branches/1.1/lib/config/sfConfigCache.class.php

    r7436 r7614  
    2424{ 
    2525  protected 
    26     $handlers = array(), 
    27     $userHandlers = array(); 
    28  
    29   protected static 
    30     $instance = null; 
    31  
    32   /** 
    33    * Retrieves the singleton instance of this class. 
    34    * 
    35    * @return sfConfigCache A sfConfigCache instance 
    36    */ 
    37   public static function getInstance() 
    38   { 
    39     if (!self::$instance) 
    40     { 
    41       self::$instance = new sfConfigCache(); 
    42     } 
    43  
    44     return self::$instance; 
     26    $configuration = null, 
     27    $handlers      = array(), 
     28    $userHandlers  = array(); 
     29 
     30  /** 
     31   * Constructor 
     32   * 
     33   * @param sfApplicationConfiguration A sfApplicationConfiguration instance 
     34   */ 
     35  public function __construct(sfApplicationConfiguration $configuration) 
     36  { 
     37    $this->configuration = $configuration; 
    4538  } 
    4639 
     
    140133   * 
    141134   * If the configuration file path is relative, symfony will look in directories  
    142    * defined in the sfLoader::getConfigPaths() method. 
     135   * defined in the sfConfiguration::getConfigPaths() method. 
    143136   * 
    144137   * @param string A filesystem path to a configuration file 
     
    148141   * @throws <b>sfConfigurationException</b> If a requested configuration file does not exist 
    149142   * 
    150    * @see sfLoader::getConfigPaths() 
     143   * @see sfConfiguration::getConfigPaths() 
    151144   */ 
    152145  public function checkConfig($configPath, $optional = false) 
     
    167160    if (!sfToolkit::isPathAbsolute($configPath)) 
    168161    { 
    169       $files = sfLoader::getConfigPaths($configPath); 
     162      $files = $this->configuration->getConfigPaths($configPath); 
    170163    } 
    171164    else 
  • branches/1.1/lib/config/sfFactoryConfigHandler.class.php

    r7518 r7614  
    155155                     "    \$class = sfConfig::get('sf_factory_i18n', '%s');\n". 
    156156                     "%s". 
    157                      "    \$this->factories['i18n'] = new \$class(\$this->dispatcher, \$cache, %s);\n". 
     157                     "    \$this->factories['i18n'] = new \$class(\$this->configuration, \$cache, %s);\n". 
    158158                     "  }\n" 
    159159                     , $class, $cache, var_export($parameters, true) 
  • branches/1.1/lib/config/sfGeneratorConfigHandler.class.php

    r6457 r7614  
    6060 
    6161    // generate class and add a reference to it 
    62     $generatorManager = new sfGeneratorManager(); 
     62    $generatorManager = new sfGeneratorManager(sfContext::getInstance()->getConfiguration()); 
    6363 
    6464    // generator parameters 
  • branches/1.1/lib/config/sfLoader.class.php

    r7302 r7614  
    1919class sfLoader 
    2020{ 
    21   /** 
    22    * Gets directories where model classes are stored. 
    23    * 
    24    * @return array An array of directories 
    25    */ 
    26   static public function getModelDirs() 
    27   { 
    28     $dirs = array(sfConfig::get('sf_lib_dir').'/model' ? sfConfig::get('sf_lib_dir').'/model' : 'lib/model'); // project 
    29     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/lib/model')) 
    30     { 
    31       $dirs = array_merge($dirs, $pluginDirs);                                                                // plugins 
    32     } 
    33  
    34     return $dirs; 
    35   } 
    36  
    37   /** 
    38    * Gets directories where controller classes are stored for a given module. 
    39    * 
    40    * @param string The module name 
    41    * 
    42    * @return array An array of directories 
    43    */ 
    44   static public function getControllerDirs($moduleName) 
    45   { 
    46     $suffix = $moduleName.'/'.sfConfig::get('sf_app_module_action_dir_name'); 
    47  
    48     $dirs = array(); 
    49     foreach (sfConfig::get('sf_module_dirs', array()) as $key => $value) 
    50     { 
    51       $dirs[$key.'/'.$suffix] = $value; 
    52     } 
    53  
    54     $dirs[sfConfig::get('sf_app_module_dir').'/'.$suffix] = false;                                     // application 
    55  
    56     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/modules/'.$suffix)) 
    57     { 
    58       $dirs = array_merge($dirs, array_combine($pluginDirs, array_fill(0, count($pluginDirs), true))); // plugins 
    59     } 
    60  
    61     $dirs[sfConfig::get('sf_symfony_lib_dir').'/controller/'.$suffix] = true;                          // core modules 
    62  
    63     return $dirs; 
    64   } 
    65  
    66   /** 
    67    * Gets directories where template files are stored for a given module. 
    68    * 
    69    * @param string The module name 
    70    * 
    71    * @return array An array of directories 
    72    */ 
    73   static public function getTemplateDirs($moduleName) 
    74   { 
    75     $suffix = $moduleName.'/'.sfConfig::get('sf_app_module_template_dir_name'); 
    76  
    77     $dirs = array(); 
    78     foreach (sfConfig::get('sf_module_dirs', array()) as $key => $value) 
    79     { 
    80       $dirs[] = $key.'/'.$suffix; 
    81     } 
    82  
    83     $dirs[] = sfConfig::get('sf_app_module_dir').'/'.$suffix;                        // application 
    84  
    85     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/modules/'.$suffix)) 
    86     { 
    87       $dirs = array_merge($dirs, $pluginDirs);                                       // plugins 
    88     } 
    89  
    90     $dirs[] = sfConfig::get('sf_symfony_lib_dir').'/controller/'.$suffix;            // core modules 
    91     $dirs[] = sfConfig::get('sf_module_cache_dir').'/auto'.ucfirst($suffix);         // generated templates in cache 
    92  
    93     return $dirs; 
    94   } 
    95  
    96   /** 
    97    * Gets the template directory to use for a given module and template file. 
    98    * 
    99    * @param string The module name 
    100    * @param string The template file 
    101    * 
    102    * @return string A template directory 
    103    */ 
    104   static public function getTemplateDir($moduleName, $templateFile) 
    105   { 
    106     $dirs = self::getTemplateDirs($moduleName); 
    107     foreach ($dirs as $dir) 
    108     { 
    109       if (is_readable($dir.'/'.$templateFile)) 
    110       { 
    111         return $dir; 
    112       } 
    113     } 
    114  
    115     return null; 
    116   } 
    117  
    118   /** 
    119    * Gets the template to use for a given module and template file. 
    120    * 
    121    * @param string The module name 
    122    * @param string The template file 
    123    * 
    124    * @return string A template path 
    125    */ 
    126   static public function getTemplatePath($moduleName, $templateFile) 
    127   { 
    128     $dir = self::getTemplateDir($moduleName, $templateFile); 
    129  
    130     return $dir ? $dir.'/'.$templateFile : null; 
    131   } 
    132  
    133   /** 
    134    * Gets the i18n directories to use globally. 
    135    * 
    136    * @return array An array of i18n directories 
    137    */ 
    138   static public function getI18NGlobalDirs() 
    139   { 
    140     $dirs = array(); 
    141  
    142     // application 
    143     if (is_dir($dir = sfConfig::get('sf_app_dir').'/'.sfConfig::get('sf_app_module_i18n_dir_name'))) 
    144     { 
    145       $dirs[] = $dir; 
    146     } 
    147  
    148     // plugins 
    149     $pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.sfConfig::get('sf_app_module_i18n_dir_name')); 
    150     if (isset($pluginDirs[0])) 
    151     { 
    152       $dirs[] = $pluginDirs[0]; 
    153     } 
    154  
    155     return $dirs; 
    156   } 
    157  
    158   /** 
    159    * Gets the i18n directories to use for a given module. 
    160    * 
    161    * @param string The module name 
    162    * 
    163    * @return array An array of i18n directories 
    164    */ 
    165   static public function getI18NDirs($moduleName) 
    166   { 
    167     $dirs = array(); 
    168  
    169     // module 
    170     if (is_dir($dir = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_i18n_dir_name'))) 
    171     { 
    172       $dirs[] = $dir; 
    173     } 
    174  
    175     // application 
    176     if (is_dir($dir = sfConfig::get('sf_app_dir').'/'.sfConfig::get('sf_app_module_i18n_dir_name'))) 
    177     { 
    178       $dirs[] = $dir; 
    179     } 
    180  
    181     // module in plugins 
    182     $pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/modules/'.$moduleName.'/'.sfConfig::get('sf_app_module_i18n_dir_name')); 
    183     if (isset($pluginDirs[0])) 
    184     { 
    185       $dirs[] = $pluginDirs[0]; 
    186     } 
    187  
    188     // plugins 
    189     $pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.sfConfig::get('sf_app_module_i18n_dir_name')); 
    190     if (isset($pluginDirs[0])) 
    191     { 
    192       $dirs[] = $pluginDirs[0]; 
    193     } 
    194  
    195     return $dirs; 
    196   } 
    197  
    198   /** 
    199    * Gets directories where template files are stored for a generator class and a specific theme. 
    200    * 
    201    * @param string The generator class name 
    202    * @param string The theme name 
    203    * 
    204    * @return array An array of directories 
    205    */ 
    206   static public function getGeneratorTemplateDirs($class, $theme) 
    207   { 
    208     $dirs = array(sfConfig::get('sf_data_dir').'/generator/'.$class.'/'.$theme.'/template');                  // project 
    209  
    210     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/data/generator/'.$class.'/'.$theme.'/template')) 
    211     { 
    212       $dirs = array_merge($dirs, $pluginDirs);                                                                // plugin 
    213     } 
    214  
    215     if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/data/generator/'.$class.'/'.$theme.'/template')) 
    216     { 
    217       $dirs = array_merge($dirs, $bundledPluginDirs);                                                         // bundled plugin 
    218     } 
    219  
    220     return $dirs; 
    221   } 
    222  
    223   /** 
    224    * Gets directories where the skeleton is stored for a generator class and a specific theme. 
    225    * 
    226    * @param string The generator class name 
    227    * @param string The theme name 
    228    * 
    229    * @return array An array of directories 
    230    */ 
    231   static public function getGeneratorSkeletonDirs($class, $theme) 
    232   { 
    233     $dirs = array(sfConfig::get('sf_data_dir').'/generator/'.$class.'/'.$theme.'/skeleton');                  // project 
    234  
    235     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/data/generator/'.$class.'/'.$theme.'/skeleton')) 
    236     { 
    237       $dirs = array_merge($dirs, $pluginDirs);                                                                // plugin 
    238     } 
    239  
    240     if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/data/generator/'.$class.'/'.$theme.'/skeleton')) 
    241     { 
    242       $dirs = array_merge($dirs, $bundledPluginDirs);                                                         // bundled plugin 
    243     } 
    244  
    245     return $dirs; 
    246   } 
    247  
    248   /** 
    249    * Gets the template to use for a generator class. 
    250    * 
    251    * @param string The generator class name 
    252    * @param string The theme name 
    253    * @param string The template path 
    254    * 
    255    * @return string A template path 
    256    * 
    257    * @throws sfException 
    258    */ 
    259   static public function getGeneratorTemplate($class, $theme, $path) 
    260   { 
    261     $dirs = self::getGeneratorTemplateDirs($class, $theme); 
    262     foreach ($dirs as $dir) 
    263     { 
    264       if (is_readable($dir.'/'.$path)) 
    265       { 
    266         return $dir.'/'.$path; 
    267       } 
    268     } 
    269  
    270     throw new sfException(sprintf('Unable to load "%s" generator template in: %s.', $path, implode(', ', $dirs))); 
    271   } 
    272  
    273   /** 
    274    * Gets the configuration file paths for a given relative configuration path. 
    275    * 
    276    * @param string The configuration path 
    277    * 
    278    * @return array An array of paths 
    279    */ 
    280   static public function getConfigPaths($configPath) 
    281   { 
    282     $globalConfigPath = basename(dirname($configPath)).'/'.basename($configPath); 
    283  
    284     $files = array( 
    285       sfConfig::get('sf_symfony_lib_dir').'/config/'.$globalConfigPath,              // symfony 
    286     ); 
    287  
    288     if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/'.$globalConfigPath)) 
    289     { 
    290       $files = array_merge($files, $bundledPluginDirs);                              // bundled plugins 
    291     } 
    292  
    293     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.$globalConfigPath)) 
    294     { 
    295       $files = array_merge($files, $pluginDirs);                                     // plugins 
    296     } 
    297  
    298     $files = array_merge($files, array( 
    299       sfConfig::get('sf_root_dir').'/'.$globalConfigPath,                            // project 
    300       sfConfig::get('sf_root_dir').'/'.$configPath,                                  // project 
    301       sfConfig::get('sf_app_dir').'/'.$globalConfigPath,                             // application 
    302       sfConfig::get('sf_app_cache_dir').'/'.$configPath,                             // generated modules 
    303     )); 
    304  
    305     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.$configPath)) 
    306     { 
    307       $files = array_merge($files, $pluginDirs);                                     // plugins 
    308     } 
    309  
    310     $files[] = sfConfig::get('sf_app_dir').'/'.$configPath;                          // module 
    311  
    312     $configs = array(); 
    313     foreach (array_unique($files) as $file) 
    314     { 
    315       if (is_readable($file)) 
    316       { 
    317         $configs[] = $file; 
    318       } 
    319     } 
    320  
    321     return $configs; 
    322   } 
    323  
    32421  /** 
    32522   * Gets the helper directories for a given module name. 
     
    412109    } 
    413110  } 
    414  
    415   /** 
    416    * Loads config.php files from plugins 
    417    * 
    418    * @return void 
    419    */ 
    420   static public function loadPluginConfig() 
    421   { 
    422     if ($pluginConfigs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/config/config.php')) 
    423     { 
    424       foreach($pluginConfigs as $config) 
    425       { 
    426         require_once($config); 
    427       } 
    428     } 
    429  
    430     if ($pluginConfigs = glob(sfConfig::get('sf_plugins_dir').'/*/config/config.php')) 
    431     { 
    432       foreach ($pluginConfigs as $config) 
    433       { 
    434         require_once($config); 
    435       } 
    436     } 
    437   } 
    438111} 
  • branches/1.1/lib/controller/default/templates/moduleSuccess.php

    r7329 r7614  
    1515  <dd> 
    1616    <ul class="sfTIconList"> 
    17       <li class="sfTDirectoryMessage">Browse to the <code>apps/<?php echo SF_APP ?>/modules/<?php echo $sf_params->get('module') ?>/</code> directory</li> 
     17      <li class="sfTDirectoryMessage">Browse to the <code>apps/<?php echo sfContext::getInstance()->getConfiguration()->getApplication() ?>/modules/<?php echo $sf_params->get('module') ?>/</code> directory</li> 
    1818      <li class="sfTEditMessage">In <code>actions/actions.class.php</code>, edit the <code>executeIndex()</code> method and remove the final <code>forward</code></li> 
    1919      <li class="sfTColorMessage">Customize the <code>templates/indexSuccess.php</code> template</li> 
  • branches/1.1/lib/controller/sfController.class.php

    r7215 r7614  
    9999  protected function controllerExists($moduleName, $controllerName, $extension, $throwExceptions) 
    100100  { 
    101     $dirs = sfLoader::getControllerDirs($moduleName); 
     101    $dirs = $this->context->getConfiguration()->getControllerDirs($moduleName); 
    102102    foreach ($dirs as $dir => $checkEnabled) 
    103103    { 
     
    195195 
    196196    // check for a module generator config file 
    197     sfConfigCache::getInstance()->import(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/generator.yml', true, true); 
     197    $this->context->getConfigCache()->import(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/generator.yml', true, true); 
    198198 
    199199    if (!$this->actionExists($moduleName, $actionName)) 
     
    215215 
    216216    // include module configuration 
    217     require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml')); 
     217    require($this->context->getConfigCache()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml')); 
    218218 
    219219    // check if this module is internal 
  • branches/1.1/lib/database/sfDatabaseManager.class.php

    r7442 r7614  
    2424{ 
    2525  protected 
    26     $databases = array(); 
     26    $configuration = null, 
     27    $databases     = array(); 
    2728 
    2829  /** 
     
    3132   * @see initialize() 
    3233   */ 
    33   public function __construct($options = array()) 
     34  public function __construct(sfApplicationConfiguration $configuration, $options = array()) 
    3435  { 
    35     $this->initialize(); 
     36    $this->initialize($configuration); 
    3637 
    3738    if (isset($options['auto_shutdown']) && $options['auto_shutdown']) 
     
    4445   * Initializes this sfDatabaseManager object 
    4546   * 
     47   * @param  sfApplicationConfiguration A sfApplicationConfiguration instance 
     48   * 
    4649   * @return bool true, if initialization completes successfully, otherwise false 
    4750   * 
    4851   * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfDatabaseManager object 
    4952   */ 
    50   public function initialize(
     53  public function initialize(sfApplicationConfiguration $configuration
    5154  { 
     55    $this->configuration = $configuration; 
     56 
    5257    $this->loadConfiguration(); 
    5358  } 
     
    5863  public function loadConfiguration() 
    5964  { 
    60     require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/databases.yml')); 
     65    require($this->configuration->getConfigCache()->checkConfig('config/databases.yml')); 
    6166  } 
    6267 
  • branches/1.1/lib/filter/sfFilterChain.class.php

    r6499 r7614  
    3232  public function loadConfiguration($actionInstance) 
    3333  { 
    34     require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$actionInstance->getModuleName().'/'.sfConfig::get('sf_app_module_config_dir_name').'/filters.yml')); 
     34    require(sfContext::getInstance()->getConfigCache()->checkConfig('modules/'.$actionInstance->getModuleName().'/config/filters.yml')); 
    3535  } 
    3636 
  • branches/1.1/lib/generator/sfCrudGenerator.class.php

    r7480 r7614  
    7272    // theme exists? 
    7373    $theme = isset($this->params['theme']) ? $this->params['theme'] : 'default'; 
    74     $themeDir = sfLoader::getGeneratorTemplate($this->getGeneratorClass(), $theme, ''); 
     74    $themeDir = $this->generatorManager->getConfiguration()->getGeneratorTemplate($this->getGeneratorClass(), $theme, ''); 
    7575    if (!is_dir($themeDir)) 
    7676    { 
  • branches/1.1/lib/generator/sfGenerator.class.php

    r6156 r7614  
    7878  protected function evalTemplate($templateFile) 
    7979  { 
    80     $templateFile = sfLoader::getGeneratorTemplate($this->getGeneratorClass(), $this->getTheme(), $templateFile); 
     80    $templateFile = $this->generatorManager->getConfiguration()->getGeneratorTemplate($this->getGeneratorClass(), $this->getTheme(), $templateFile); 
    8181 
    8282    // eval template file 
  • branches/1.1/lib/generator/sfGeneratorManager.class.php

    r4957 r7614  
    1919class sfGeneratorManager 
    2020{ 
     21  protected 
     22    $configuration = null; 
     23 
    2124  /** 
    2225   * Class constructor. 
    2326   * 
     27   * @param sfProjectConfiguration A sfProjectConfiguration instance 
     28   * 
    2429   * @see initialize() 
    2530   */ 
    26   public function __construct(
     31  public function __construct(sfProjectConfiguration $configuration
    2732  { 
    28     $this->initialize(); 
     33    $this->initialize($configuration); 
    2934  } 
    3035 
    3136  /** 
    3237   * Initializes the sfGeneratorManager instance. 
     38   * 
     39   * @param sfProjectConfiguration A sfProjectConfiguration instance 
    3340   */ 
    34   public function initialize(
     41  public function initialize(sfProjectConfiguration $configuration
    3542  { 
     43    $this->configuration = $configuration; 
     44  } 
     45 
     46  /** 
     47   * Returns the current configuration instance. 
     48   * 
     49   * @return sfProjectConfiguration A sfProjectConfiguration instance 
     50   */ 
     51  public function getConfiguration() 
     52  { 
     53    return $this->configuration; 
    3654  } 
    3755 
  • branches/1.1/lib/i18n/extract/sfI18nModuleExtract.class.php

    r4359 r7614  
    3131    $this->module = $this->parameters['module']; 
    3232 
    33     $this->i18n->setMessageSource(sfLoader::getI18NDirs($this->module), $this->culture); 
     33    $this->i18n->setMessageSource($this->i18n->getConfiguration()->getI18NDirs($this->module), $this->culture); 
    3434  } 
    3535 
  • branches/1.1/lib/i18n/sfI18N.class.php

    r6721 r7614  
    2020{ 
    2121  protected 
     22    $configuration = null, 
    2223    $dispatcher    = null, 
    2324    $cache         = null, 
     
    3233   * @see initialize() 
    3334   */ 
    34   public function __construct(sfEventDispatcher $dispatcher, sfCache $cache = null, $options = array()) 
    35   { 
    36     $this->initialize($dispatcher, $cache, $options); 
     35  public function __construct(sfApplicationConfiguration $configuration, sfCache $cache = null, $options = array()) 
     36  { 
     37    $this->initialize($configuration, $cache, $options); 
    3738  } 
    3839 
     
    4041   * Initializes this class. 
    4142   * 
    42    * @param sfEventDispatcher A sfEventDispatcher implementation instance 
    43    * @param sfCache           A sfCache instance 
    44    * @param array             An array of options 
    45    */ 
    46   public function initialize(sfEventDispatcher $dispatcher, sfCache $cache = null, $options = array()) 
    47   { 
    48     $this->dispatcher = $dispatcher; 
    49     $this->cache      = $cache; 
     43   * @param sfApplicationConfiguration A sfApplicationConfiguration instance 
     44   * @param sfCache                    A sfCache instance 
     45   * @param array                      An array of options 
     46   */ 
     47  public function initialize(sfApplicationConfiguration $configuration, sfCache $cache = null, $options = array()) 
     48  { 
     49    $this->configuration = $configuration; 
     50    $this->dispatcher = $configuration->getEventDispatcher(); 
     51    $this->cache = $cache; 
    5052 
    5153    if (isset($options['culture'])) 
     
    6365    ), $options); 
    6466 
    65     $dispatcher->connect('user.change_culture', array($this, 'listenToChangeCultureEvent')); 
    66     $dispatcher->connect('controller.change_action', array($this, 'listenToChangeActionEvent')); 
     67    $this->dispatcher->connect('user.change_culture', array($this, 'listenToChangeCultureEvent')); 
     68    $this->dispatcher->connect('controller.change_action', array($this, 'listenToChangeActionEvent')); 
     69  } 
     70 
     71  /** 
     72   * Returns the configuration instance. 
     73   * 
     74   * @return sfApplicationConfiguration An sfApplicationConfiguration instance 
     75   */ 
     76  public function getConfiguration() 
     77  { 
     78    return $this->configuration; 
    6779  } 
    6880 
     
    148160    if (!isset($this->messageSource)) 
    149161    { 
    150       $this->setMessageSource(sfLoader::getI18NGlobalDirs(), $this->culture); 
     162      $this->setMessageSource($this->configuration->getI18NGlobalDirs(), $this->culture); 
    151163    } 
    152164 
     
    314326  { 
    315327    // change message source directory to our module 
    316     $this->setMessageSource(sfLoader::getI18NDirs($event['module'])); 
     328    $this->setMessageSource($this->configuration->getI18NDirs($event['module'])); 
    317329  } 
    318330} 
  • branches/1.1/lib/plugins/sfCompat10Plugin/config/config.php

    r6713 r7614  
    1313 
    1414  // register config handler for validate/*.yml files 
    15   sfConfigCache::getInstance()->registerConfigHandler('modules/*/validate/*.yml', 'sfValidatorConfigHandler'); 
     15  sfProjectConfiguration::getActive()->getConfigCache()->registerConfigHandler('modules/*/validate/*.yml', 'sfValidatorConfigHandler'); 
    1616 
    1717  // register the validation execution filter 
  • branches/1.1/lib/plugins/sfCompat10Plugin/lib/filter/sfValidationExecutionFilter.class.php

    r5814 r7614  
    113113    // load validation configuration 
    114114    // do NOT use require_once 
    115     if (null !== $validateFile = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfig, true)) 
     115    if (null !== $validateFile = $this->context->getConfigCache()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfig, true)) 
    116116    { 
    117117      // create validator manager 
  • branches/1.1/lib/plugins/sfCompat10Plugin/lib/helper/PartialHelper.php

    r6624 r7614  
    133133 
    134134  // load component's module config file 
    135   require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml')); 
     135  require(sfContext::getInstance()->getConfigCache()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml')); 
    136136 
    137137  $componentInstance->getVarHolder()->add($vars); 
  • branches/1.1/lib/plugins/sfCompat10Plugin/lib/view/sfMailView.class.php

    r5106 r7614  
    4040    // require our configuration 
    4141    $moduleName = $this->moduleName; 
    42     require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$this->moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/mailer.yml')); 
     42    require($this->context->getConfigCache()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$this->moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/mailer.yml')); 
    4343  } 
    4444 
  • branches/1.1/lib/plugins/sfCompat10Plugin/test/bootstrap/functional.php

    r5384 r7614  
    1313  $root_dir = realpath(dirname(__FILE__).sprintf('/../%s/fixtures', isset($type) ? $type : 'functional')); 
    1414} 
    15 define('SF_ROOT_DIR',    $root_dir); 
    16 define('SF_APP',         $app); 
    17 define('SF_ENVIRONMENT', 'test'); 
    18 define('SF_DEBUG',       isset($debug) ? $debug : true); 
    1915 
    20 // initialize symfony 
    21 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
     16$class = $app.'Configuration'; 
     17require $root_dir.'/lib/'.$class.'.class.php'; 
     18$configuration = new $class('test', isset($debug) ? $debug : true); 
     19sfContext::createInstance($configuration); 
    2220 
    2321// remove all cache 
  • branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/symfony

    r7433 r7614  
    1111 
    1212chdir(dirname(__FILE__)); 
    13 include('config/config.php'); 
    14 include($sf_symfony_lib_dir.'/command/cli.php'); 
     13require_once(dirname(__FILE__).'/lib/ProjectConfiguration.class.php'); 
     14$configuration = new ProjectConfiguration(); 
     15include($configuration->getSymfonyLibDir().'/command/cli.php'); 
  • branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/functional.php

    r5320 r7614  
    44 * This file is part of the symfony package. 
    55 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    6  *  
     6 * 
    77 * For the full copyright and license information, please view the LICENSE 
    88 * file that was distributed with this source code. 
     
    1414  $traces = debug_backtrace(); 
    1515  $caller = $traces[0]; 
    16   $app = array_pop(explode(DIRECTORY_SEPARATOR, dirname($caller['file']))); 
     16 
     17  $dirPieces = explode(DIRECTORY_SEPARATOR, dirname($caller['file'])); 
     18  $app = array_pop($dirPieces); 
    1719} 
    1820 
    19 // define symfony constant 
    20 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/../..')); 
    21 define('SF_APP',         $app); 
    22 define('SF_ENVIRONMENT', 'test'); 
    23 define('SF_DEBUG',       true); 
     21$class = $app.'Configuration'; 
     22require_once(dirname(__FILE__).'/../../lib/'.$class.'.class.php'); 
    2423 
    25 // initialize symfony 
    26 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
     24$configuration = new $class('test', true); 
     25sfContext::createInstance($configuration); 
    2726 
    2827// remove all cache 
  • branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/unit.php

    r5320 r7614  
    1010 
    1111$_test_dir = realpath(dirname(__FILE__).'/..'); 
    12 define('SF_ROOT_DIR', realpath($_test_dir.'/..')); 
    1312 
    14 // symfony directories 
    15 include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    16  
    17 require_once($sf_symfony_lib_dir.'/vendor/lime/lime.php'); 
     13require_once(dirname(__FILE__).'/../../lib/ProjectConfiguration.class.php'); 
     14$configuration = new ProjectConfiguration(realpath($_test_dir.'/..')); 
     15include($configuration->getSymfonyLibDir().'/vendor/lime/lime.php'); 
  • branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/frontend_dev.php

    r5320 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'frontend'); 
    5 define('SF_ENVIRONMENT', 'dev'); 
    6 define('SF_DEBUG',       true); 
     3require_once(dirname(__FILE__).'/../lib/frontendConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new frontendConfiguration('dev', true); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/index.php

    r5320 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'frontend'); 
    5 define('SF_ENVIRONMENT', 'prod'); 
    6 define('SF_DEBUG',       false); 
     3require_once(dirname(__FILE__).'/../lib/frontendConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new frontendConfiguration('prod', false); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/lib/plugins/sfPropelPlugin/config/config.php

    r5100 r7614  
    11<?php 
    22 
    3 set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/../lib/vendor'); 
     3set_include_path(sfConfig::get('sf_root_dir').PATH_SEPARATOR.get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/../lib/vendor'); 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelCrudGenerator.class.php

    r4951 r7614  
    6767  { 
    6868    // we must load all map builder classes to be able to deal with foreign keys (cf. editSuccess.php template) 
    69     $classes = sfFinder::type('file')->name('*MapBuilder.php')->in(sfLoader::getModelDirs()); 
     69    $classes = sfFinder::type('file')->name('*MapBuilder.php')->in($this->generatorManager->getConfiguration()->getModelDirs()); 
    7070    foreach ($classes as $class) 
    7171    { 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php

    r7153 r7614  
    429429  protected function loadBuilders() 
    430430  { 
    431     $classes = sfFinder::type('file')->name('*MapBuilder.php')->in(sfLoader::getModelDirs()); 
     431    $classes = sfFinder::type('file')->name('*MapBuilder.php')->in($this->generatorManager->getConfiguration()->getModelDirs()); 
    432432    foreach ($classes as $class) 
    433433    { 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelAutoload.php

    r6970 r7614  
    1717require_once 'propel/Propel.php'; 
    1818 
    19 $dispatcher = sfContext::getInstance()->getEventDispatcher(); 
     19$dispatcher = sfProjectConfiguration::getActive()->getEventDispatcher(); 
    2020 
    2121if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelData.class.php

    r7399 r7614  
    271271  protected function loadMapBuilders() 
    272272  { 
    273     $files = sfFinder::type('file')->name('*MapBuilder.php')->in(sfLoader::getModelDirs()); 
     273    $files = sfFinder::type('file')->name('*MapBuilder.php')->in(sfProjectConfiguration::getActive()->getModelDirs()); 
    274274    foreach ($files as $file) 
    275275    { 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelManyToMany.class.php

    r6970 r7614  
    5252 
    5353    // we must load all map builder classes 
    54     $classes = sfFinder::type('file')->name('*MapBuilder.php')->in(sfLoader::getModelDirs()); 
     54    $classes = sfFinder::type('file')->name('*MapBuilder.php')->in(sfProjectConfiguration::getActive()->getModelDirs()); 
    5555    foreach ($classes as $class) 
    5656    { 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBaseTask.class.php

    r7476 r7614  
    3333    if (!self::$done) 
    3434    { 
     35      set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/../vendor'); 
     36 
    3537      $libDir = dirname(__FILE__).'/..'; 
    3638 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildFormsTask.class.php

    r7398 r7614  
    6161    $this->logSection('propel', 'generating form classes'); 
    6262 
    63     $generatorManager = new sfGeneratorManager(); 
     63    $generatorManager = new sfGeneratorManager($this->configuration); 
    6464 
    6565    $generatorManager->generate('sfPropelFormGenerator', array('connection' => $options['connection'])); 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataDumpTask.class.php

    r7447 r7614  
    6969  protected function execute($arguments = array(), $options = array()) 
    7070  { 
     71    $configuration = sfApplicationConfiguration::getForApplication($arguments['application'], $options['env'], true); 
     72 
     73    $databaseManager = new sfDatabaseManager($configuration); 
     74 
    7175    $filename = $arguments['target']; 
    72  
    73     $this->bootstrapSymfony($arguments['application'], $options['env'], true); 
    74  
    75     $databaseManager = new sfDatabaseManager(); 
    76  
    7776    if (!is_null($filename) && !sfToolkit::isPathAbsolute($filename)) 
    7877    { 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataLoadTask.class.php

    r7447 r7614  
    7171  protected function execute($arguments = array(), $options = array()) 
    7272  { 
    73     $this->bootstrapSymfony($arguments['application'], $options['env'], true); 
    74  
    7573    if (count($options['dir'])) 
    7674    { 
     
    8684    } 
    8785 
    88     $databaseManager = new sfDatabaseManager(); 
     86    $configuration = sfApplicationConfiguration::getForApplication($arguments['application'], $options['env'], true); 
     87 
     88    $databaseManager = new sfDatabaseManager($configuration); 
    8989 
    9090    $data = new sfPropelData(); 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelGenerateCrudTask.class.php

    r7435 r7614  
    9393    $tmpDir = sfConfig::get('sf_cache_dir').DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.md5(uniqid(rand(), true)); 
    9494    sfConfig::set('sf_module_cache_dir', $tmpDir); 
    95     $generatorManager = new sfGeneratorManager(); 
     95    $generatorManager = new sfGeneratorManager($this->configuration); 
    9696    $generatorManager->generate('sfPropelCrudGenerator', array( 
    9797      'model_class'           => $arguments['model'], 
     
    136136    // create basic application structure 
    137137    $finder = sfFinder::type('any')->ignore_version_control()->discard('.sf'); 
    138     $dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelCrud', $options['theme']); 
     138    $dirs = $this->configuration->getGeneratorSkeletonDirs('sfPropelCrud', $options['theme']); 
    139139    foreach ($dirs as $dir) 
    140140    { 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInitAdminTask.class.php

    r7401 r7614  
    7878    // create module structure 
    7979    $finder = sfFinder::type('any')->ignore_version_control()->discard('.sf'); 
    80     $dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelAdmin', $options['theme']); 
     80    $dirs = $this->configuration->getGeneratorSkeletonDirs('sfPropelAdmin', $options['theme']); 
    8181    foreach ($dirs as $dir) 
    8282    { 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/bootstrap/functional.php

    r7183 r7614  
    1919  $root_dir = realpath(dirname(__FILE__).sprintf('/../%s/fixtures', isset($type) ? $type : 'functional')); 
    2020} 
    21 define('SF_ROOT_DIR',    $root_dir); 
    22 define('SF_APP',         $app); 
    23 define('SF_ENVIRONMENT', 'test'); 
    24 define('SF_DEBUG',       isset($debug) ? $debug : true); 
    2521 
    26 // initialize symfony 
    27 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
     22$class = $app.'Configuration'; 
     23require $root_dir.'/lib/'.$class.'.class.php'; 
     24$configuration = new $class('test', isset($debug) ? $debug : true); 
     25sfContext::createInstance($configuration); 
    2826 
    2927// remove all cache 
     
    6260{ 
    6361  // initialize database manager 
    64   $databaseManager = new sfDatabaseManager(); 
     62  $databaseManager = new sfDatabaseManager($configuration); 
    6563 
    6664  // cleanup database 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/backendTestBrowser.class.php

    r6482 r7614  
    4646    $params['moduleName']  = $this->moduleName; 
    4747    sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir')); 
    48     $generatorManager = new sfGeneratorManager(); 
    49     mkdir(sfConfig::get('sf_config_cache_dir'), 0777); 
     48    $generatorManager = new sfGeneratorManager($this->getContext()->getConfiguration()); 
     49    if (!is_dir(sfConfig::get('sf_config_cache_dir'))) 
     50    { 
     51      mkdir(sfConfig::get('sf_config_cache_dir'), 0777); 
     52    } 
    5053    file_put_contents(sprintf('%s/modules_%s_config_generator.yml.php', sfConfig::get('sf_config_cache_dir'), $this->moduleName), '<?php '.$generatorManager->generate('sfPropelAdminGenerator', $params)); 
    5154 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/symfony

    r7433 r7614  
    1111 
    1212chdir(dirname(__FILE__)); 
    13 include('config/config.php'); 
    14 include($sf_symfony_lib_dir.'/command/cli.php'); 
     13require_once(dirname(__FILE__).'/lib/ProjectConfiguration.class.php'); 
     14$configuration = new ProjectConfiguration(); 
     15include($configuration->getSymfonyLibDir().'/command/cli.php'); 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/functional.php

    r5260 r7614  
    44 * This file is part of the symfony package. 
    55 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    6  *  
     6 * 
    77 * For the full copyright and license information, please view the LICENSE 
    88 * file that was distributed with this source code. 
     
    1414  $traces = debug_backtrace(); 
    1515  $caller = $traces[0]; 
    16   $app = array_pop(explode(DIRECTORY_SEPARATOR, dirname($caller['file']))); 
     16 
     17  $dirPieces = explode(DIRECTORY_SEPARATOR, dirname($caller['file'])); 
     18  $app = array_pop($dirPieces); 
    1719} 
    1820 
    19 // define symfony constant 
    20 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/../..')); 
    21 define('SF_APP',         $app); 
    22 define('SF_ENVIRONMENT', 'test'); 
    23 define('SF_DEBUG',       true); 
     21$class = $app.'Configuration'; 
     22require_once(dirname(__FILE__).'/../../lib/'.$class.'.class.php'); 
    2423 
    25 // initialize symfony 
    26 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
     24$configuration = new $class('test', true); 
     25sfContext::createInstance($configuration); 
    2726 
    2827// remove all cache 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/unit.php

    r5103 r7614  
    1010 
    1111$_test_dir = realpath(dirname(__FILE__).'/..'); 
    12 define('SF_ROOT_DIR', realpath($_test_dir.'/..')); 
    1312 
    14 // symfony directories 
    15 include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    16  
    17 require_once($sf_symfony_lib_dir.'/vendor/lime/lime.php'); 
     13require_once(dirname(__FILE__).'/../../lib/ProjectConfiguration.class.php'); 
     14$configuration = new ProjectConfiguration(realpath($_test_dir.'/..')); 
     15include($configuration->getSymfonyLibDir().'/vendor/lime/lime.php'); 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/backend_dev.php

    r5103 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'backend'); 
    5 define('SF_ENVIRONMENT', 'dev'); 
    6 define('SF_DEBUG',       true); 
     3require_once(dirname(__FILE__).'/../lib/backendConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new backendConfiguration('dev', true); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud.php

    r5103 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'crud'); 
    5 define('SF_ENVIRONMENT', 'prod'); 
    6 define('SF_DEBUG',       false); 
     3require_once(dirname(__FILE__).'/../lib/crudConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new crudConfiguration('prod', false); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud_dev.php

    r5103 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'crud'); 
    5 define('SF_ENVIRONMENT', 'dev'); 
    6 define('SF_DEBUG',       true); 
     3require_once(dirname(__FILE__).'/../lib/crudConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new crudConfiguration('dev', true); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/index.php

    r5103 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'backend'); 
    5 define('SF_ENVIRONMENT', 'prod'); 
    6 define('SF_DEBUG',       false); 
     3require_once(dirname(__FILE__).'/../lib/backendConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new backendConfiguration('prod', false); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/lib/routing/sfPatternRouting.class.php

    r7611 r7614  
    7171  public function loadConfiguration() 
    7272  { 
    73     if ($config = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/routing.yml', true)) 
     73    if ($config = sfContext::getInstance()->getConfigCache()->checkConfig('config/routing.yml', true)) 
    7474    { 
    7575      include($config); 
  • branches/1.1/lib/task/generator/sfGenerateAppTask.class.php

    r7463 r7614  
    113113    )); 
    114114 
     115    $this->getFilesystem()->copy(dirname(__FILE__).'/skeleton/app/lib/ApplicationConfiguration.class.php', sfConfig::get('sf_lib_dir').'/'.$app.'Configuration.class.php'); 
     116 
     117    $this->getFilesystem()->replaceTokens(sfConfig::get('sf_lib_dir').'/'.$app.'Configuration.class.php', '##', '##', array('APP_NAME' => $app)); 
     118 
    115119    $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); 
    116120    $fixPerms->setCommandApplication($this->commandApplication); 
  • branches/1.1/lib/task/generator/sfGenerateProjectTask.class.php

    r7401 r7614  
    6767    } 
    6868 
    69     // Create basic project structure 
     69    // create basic project structure 
    7070    $finder = sfFinder::type('any')->ignore_version_control()->discard('.sf'); 
    7171    $this->getFilesystem()->mirror(dirname(__FILE__).'/skeleton/project', sfConfig::get('sf_root_dir'), $finder); 
    7272 
    73     // Update project name and directory 
     73    // update project name and directory 
    7474    $finder = sfFinder::type('file')->name('properties.ini', 'apache.conf', 'propel.ini'); 
    75     $this->getFilesystem()->replaceTokens($finder->in(sfConfig::get('sf_config_dir')), '##', '##', array('PROJECT_NAME' => $arguments['name'], 
    76                                                                                                     'PROJECT_DIR' => sfConfig::get('sf_root_dir'))); 
     75    $this->getFileSystem()->replaceTokens($finder->in(sfConfig::get('sf_config_dir')), '##', '##', array('PROJECT_NAME' => $arguments['name'], 'PROJECT_DIR' => sfConfig::get('sf_root_dir'))); 
    7776 
    78     // Update config/config.php 
    79     $this->getFilesystem()->replaceTokens(sfConfig::get('sf_config_dir').'/config.php', '##', '##', array( 
    80       'SYMFONY_LIB_DIR'  => sfConfig::get('sf_symfony_lib_dir'), 
    81     )); 
     77    // update ProjectConfiguration class 
     78    $this->getFileSystem()->replaceTokens(sfConfig::get('sf_lib_dir').'/ProjectConfiguration.class.php', '##', '##', array('SYMFONY_LIB_DIR'  => sfConfig::get('sf_symfony_lib_dir'))); 
    8279 
    8380    $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); 
  • branches/1.1/lib/task/generator/skeleton/app/web/index.php

    r7463 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         '##APP_NAME##'); 
    5 define('SF_ENVIRONMENT', '##ENVIRONMENT##'); 
    6 define('SF_DEBUG',       ##IS_DEBUG##); 
     3require_once(dirname(__FILE__).'/../lib/##APP_NAME##Configuration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new ##APP_NAME##Configuration('##ENVIRONMENT##', ##IS_DEBUG##); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/lib/task/generator/skeleton/project/symfony

    r7322 r7614  
    1111 
    1212chdir(dirname(__FILE__)); 
    13 include('config/config.php'); 
    14 include($sf_symfony_lib_dir.'/command/cli.php'); 
     13require_once(dirname(__FILE__).'/lib/ProjectConfiguration.class.php'); 
     14$configuration = new ProjectConfiguration(); 
     15include($configuration->getSymfonyLibDir().'/command/cli.php'); 
  • branches/1.1/lib/task/generator/skeleton/project/test/bootstrap/functional.php

    r6222 r7614  
    1919} 
    2020 
    21 // define symfony constant 
    22 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/../..')); 
    23 define('SF_APP',         $app); 
    24 define('SF_ENVIRONMENT', 'test'); 
    25 define('SF_DEBUG',       true); 
     21$class = $app.'Configuration'; 
     22require_once(dirname(__FILE__).'/../../lib/'.$class.'.class.php'); 
    2623 
    27 // initialize symfony 
    28 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
     24$configuration = new $class('test', true); 
     25sfContext::createInstance($configuration); 
    2926 
    3027// remove all cache 
  • branches/1.1/lib/task/generator/skeleton/project/test/bootstrap/unit.php

    r2369 r7614  
    1010 
    1111$_test_dir = realpath(dirname(__FILE__).'/..'); 
    12 define('SF_ROOT_DIR', realpath($_test_dir.'/..')); 
    1312 
    14 // symfony directories 
    15 include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    16  
    17 require_once($sf_symfony_lib_dir.'/vendor/lime/lime.php'); 
     13require_once(dirname(__FILE__).'/../../lib/ProjectConfiguration.class.php'); 
     14$configuration = new ProjectConfiguration(realpath($_test_dir.'/..')); 
     15include($configuration->getSymfonyLibDir().'/vendor/lime/lime.php'); 
  • branches/1.1/lib/task/i18n/sfI18nExtractTask.class.php

    r7430 r7614  
    8282  public function execute($arguments = array(), $options = array()) 
    8383  { 
    84     $this->bootstrapSymfony($arguments['application'], 'dev', true); 
    85  
    8684    $this->logSection('i18n', sprintf('extracting i18n strings for the "%s" application', $arguments['application'])); 
    8785 
    88     $extract = new sfI18nApplicationExtract(sfContext::getInstance()->getI18N(), $arguments['culture']); 
     86    $extract = new sfI18nApplicationExtract(new sfI18N($this->configuration, new sfNoCache()), $arguments['culture']); 
    8987    $extract->extract(); 
    9088 
  • branches/1.1/lib/task/i18n/sfI18nFindTask.class.php

    r7397 r7614  
    4646  { 
    4747    $this->logSection('i18n', sprintf('find non "i18n ready" strings in the "%s" application', $arguments['application'])); 
    48  
    49     sfCore::initDirectoryLayout(sfConfig::get('sf_root_dir'), $arguments['application'], $options['env']); 
    5048 
    5149    // Look in templates 
  • branches/1.1/lib/task/project/sfProjectClearControllersTask.class.php

    r7401 r7614  
    6565    foreach ($finder->in(sfConfig::get('sf_web_dir')) as $controller) 
    6666    { 
    67       $contents = file_get_contents($controller); 
    68       preg_match('/\'SF_APP\',[\s]*\'(.*)\'\)/', $contents, $foundApp); 
    69       preg_match('/\'SF_ENVIRONMENT\',[\s]*\'(.*)\'\)/', $contents, $env); 
     67      $content = file_get_contents($controller); 
    7068 
    71       // Remove file if it has found an application and the environment is not production 
    72       if (isset($foundApp[1]) && isset($env[1]) && $env[1] != 'prod') 
     69      if (preg_match('/new (.*?)Configuration\(\'(.*?)\'/', $content, $match)) 
    7370      { 
    74         $this->getFilesystem()->remove($controller); 
     71        // Remove file if it has found an application and the environment is not production 
     72        if ($match[2] != 'prod') 
     73        { 
     74          $this->getFilesystem()->remove($controller); 
     75        } 
    7576      } 
    7677    } 
  • branches/1.1/lib/task/project/sfProjectFreezeTask.class.php

    r7401 r7614  
    7070    } 
    7171 
    72     $symfony_lib_dir  = sfConfig::get('sf_symfony_lib_dir'); 
    73     $symfony_data_dir = $arguments['symfony_data_dir']; 
     72    $symfonyLibDir  = sfConfig::get('sf_symfony_lib_dir'); 
     73    $symfonyDataDir = $arguments['symfony_data_dir']; 
    7474 
    75     $this->logSection('freeze', sprintf('freezing lib found in "%s', $symfony_lib_dir)); 
    76     $this->logSection('freeze', sprintf('freezing data found in "%s"', $symfony_data_dir)); 
     75    $this->logSection('freeze', sprintf('freezing lib found in "%s', $symfonyLibDir)); 
     76    $this->logSection('freeze', sprintf('freezing data found in "%s"', $symfonyDataDir)); 
    7777 
    7878    $this->getFilesystem()->mkdirs('lib'.DIRECTORY_SEPARATOR.'symfony'); 
    7979    $this->getFilesystem()->mkdirs('data'.DIRECTORY_SEPARATOR.'symfony'); 
    8080 
    81     $finder = sfFinder::type('any')->ignore_version_control(); 
    82     $this->getFilesystem()->mirror($symfony_lib_dir, sfConfig::get('sf_lib_dir').'/symfony', $finder); 
    83     $this->getFilesystem()->mirror($symfony_data_dir, sfConfig::get('sf_data_dir').'/symfony', $finder); 
    84  
     81    $finder = sfFinder::type('any')->ignore_version_control()->exec(array($this, 'excludeTests')); 
     82    $this->getFilesystem()->mirror($symfonyLibDir, sfConfig::get('sf_lib_dir').'/symfony', $finder); 
     83    $this->getFilesystem()->mirror($symfonyDataDir, sfConfig::get('sf_data_dir').'/symfony', $finder); 
    8584    $this->getFilesystem()->rename(sfConfig::get('sf_data_dir').'/symfony/web/sf', sfConfig::get('sf_web_dir').'/sf'); 
    8685 
    87     // change symfony paths in config/config.php 
    88     file_put_contents('config/config.php.bak', $symfony_lib_dir); 
    89     $this->changeSymfonyDirs("dirname(__FILE__).'/../lib/symfony'"); 
     86    // change symfony path in ProjectConfiguration.class.php 
     87    $config = sfConfig::get('sf_lib_dir').'/ProjectConfiguration.class.php'; 
     88    $content = file_get_contents($config); 
     89    $content = str_replace('<?php', "<?php\n\n# FROZEN_SF_LIB_DIR: $symfonyLibDir", $content); 
     90    $content = preg_replace('#(\'|")'.preg_quote($symfonyLibDir, '#').'#', "dirname(__FILE__).$1/../lib/symfony", $content); 
     91    file_put_contents($config, $content); 
    9092  } 
    9193 
    92   protected function changeSymfonyDirs($symfony_lib_dir
     94  public function excludeTests($dir, $entry
    9395  { 
    94     $content = file_get_contents('config/config.php'); 
    95     $content = preg_replace("/^(\s*.sf_symfony_lib_dir\s*=\s*).+?;/m", "$1$symfony_lib_dir;", $content); 
    96     file_put_contents('config/config.php', $content); 
     96    return false === strpos($dir.'/'.$entry, 'Plugin/test/'); 
    9797  } 
    9898} 
  • branches/1.1/lib/task/project/sfProjectUnfreezeTask.class.php

    r7401 r7614  
    5151    } 
    5252 
    53     $this->changeSymfonyDirs("'".file_get_contents('config/config.php.bak')."'"); 
     53    // change symfony path in ProjectConfiguration.class.php 
     54    $config = sfConfig::get('sf_lib_dir').'/ProjectConfiguration.class.php'; 
     55    $content = file_get_contents($config); 
     56    if (preg_match('/^# FROZEN_SF_LIB_DIR\: (.+?)$/m', $content, $match)) 
     57    { 
     58      $content = str_replace("# FROZEN_SF_LIB_DIR: {$match[1]}\n\n", '', $content); 
     59      $content = preg_replace('#^require_once.+?$#m', "require_once '{$match[1]}/autoload/sfCoreAutoload.class.php';", $content, 1); 
     60      file_put_contents($config, $content); 
     61    } 
    5462 
    5563    $finder = sfFinder::type('any'); 
     
    6068    $this->getFilesystem()->remove($finder->in(sfConfig::get('sf_web_dir').'/sf')); 
    6169    $this->getFilesystem()->remove(sfConfig::get('sf_web_dir').'/sf'); 
    62    } 
    63  
    64   protected function changeSymfonyDirs($symfony_lib_dir) 
    65   { 
    66     $content = file_get_contents('config/config.php'); 
    67     $content = preg_replace("/^(\s*.sf_symfony_lib_dir\s*=\s*).+?;/m", "$1$symfony_lib_dir;", $content); 
    68     file_put_contents('config/config.php', $content); 
    6970  } 
    7071} 
  • branches/1.1/lib/task/project/upgrade1.1/sfConfigUpgrade.class.php

    r7397 r7614  
    2121  public function upgrade() 
    2222  { 
     23    $this->checkConfigFiles(); 
     24    $this->upgradeFrontControllers(); 
     25    $this->upgradeConfigurationClasses(); 
     26  } 
     27 
     28  protected function checkConfigFiles() 
     29  { 
    2330    $finder = $this->getFinder('file')->name('config.php'); 
    2431    foreach ($finder->in($this->getProjectConfigDirectories()) as $file) 
    2532    { 
     33      $this->logSection('config', sprintf('The following file is not used anymore. Please remove it.', $file)); 
     34      $this->log('   '.$file); 
     35      $this->logSection('config', '  If you made some customization in this file,'); 
     36      $this->logSection('config', '  please migrate the content to the configuration classes.'); 
     37    } 
     38  } 
     39 
     40  protected function upgradeFrontControllers() 
     41  { 
     42    // update front web controllers only if no changes have been made 
     43    $finder = $this->getFinder('file')->name('*.php'); 
     44    foreach ($finder->in(sfConfig::get('sf_web_dir')) as $file) 
     45    { 
    2646      $content = file_get_contents($file); 
    27       $content = str_replace('sfCore::bootstrap($sf_symfony_lib_dir, $sf_symfony_data_dir)', 'sfCore::bootstrap($sf_symfony_lib_dir)', $content, $count); 
    28       if ($count) 
     47 
     48      // front controller? 
     49      if (false === strpos($content, 'define(\'SF_ROOT_DIR\'')) 
    2950      { 
    30         $this->logSection('config', sprintf('Migrating %s', $file)); 
    31         file_put_contents($file, $content); 
     51        continue; 
    3252      } 
     53 
     54      // already upgraded? 
     55      if (false !== strpos($content, 'sfContext::createInstance')) 
     56      { 
     57        continue; 
     58      } 
     59 
     60      if (!preg_match("/define\('SF_APP',\s*('|\")(.+?)\\1\)/", $content, $matches)) 
     61      { 
     62        continue; 
     63      } 
     64      $app = $matches[2]; 
     65 
     66      if (!preg_match("/define\('SF_ENVIRONMENT',\s*('|\")(.+?)\\1\)/", $content, $matches)) 
     67      { 
     68        continue; 
     69      } 
     70      $environment = $matches[2]; 
     71 
     72      if (!preg_match("/define\('SF_DEBUG',\s*(.+?)\)/", $content, $matches)) 
     73      { 
     74        continue; 
     75      } 
     76      $debug = $matches[1]; 
     77 
     78      $originalContent = <<<EOF 
     79<?php 
     80 
     81define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
     82define('SF_APP',         '$app'); 
     83define('SF_ENVIRONMENT', '$environment'); 
     84define('SF_DEBUG',       $debug); 
     85 
     86require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
     87 
     88sfContext::getInstance()->getController()->dispatch(); 
     89 
     90EOF; 
     91 
     92      $newContent = file_get_contents(dirname(__FILE__).'/../../generator/skeleton/app/web/index.php'); 
     93      $newContent = str_replace(array('##APP_NAME##', '##ENVIRONMENT##', '##IS_DEBUG##'), array($app, $environment, $debug), $newContent); 
     94 
     95      if ($originalContent == $content) 
     96      { 
     97        $content = $newContent; 
     98        $this->logSection('config', sprintf('Migrated "%s"', $file)); 
     99      } 
     100      else 
     101      { 
     102        $this->logSection('config', '  You made some customization in the following file:'); 
     103        $this->log('   '.$file); 
     104        $this->logSection('config', '  Please, upgrade manually (new code appended as a comment)'); 
     105 
     106        $content .= sprintf("\n\n/*\n%s\n*/\n", $newContent); 
     107      } 
     108 
     109      file_put_contents($file, $content); 
     110    } 
     111  } 
     112 
     113  protected function upgradeConfigurationClasses() 
     114  { 
     115    foreach ($this->getApplications() as $application) 
     116    { 
     117      if (file_exists(sfConfig::get('sf_lib_dir').'/'.$application.'Configuration.class.php')) 
     118      { 
     119        continue; 
     120      } 
     121 
     122      $this->getFilesystem()->copy(dirname(__FILE__).'/../../generator/skeleton/app/lib/ApplicationConfiguration.class.php', sfConfig::get('sf_lib_dir').'/'.$application.'Configuration.class.php'); 
     123 
     124      $this->getFilesystem()->replaceTokens(sfConfig::get('sf_lib_dir').'/'.$application.'Configuration.class.php', '##', '##', array('APP_NAME' => $application)); 
    33125    } 
    34126  } 
  • branches/1.1/lib/task/project/upgrade1.1/sfUpgrade.class.php

    r7409 r7614  
    100100    ); 
    101101  } 
     102 
     103  /** 
     104   * Returns all application names. 
     105   * 
     106   * @return array An array of application names 
     107   */ 
     108  protected function getApplications() 
     109  { 
     110    return sfFinder::type('dir')->maxdepth(0)->ignore_version_control()->relative()->in(sfConfig::get('sf_apps_dir')); 
     111  } 
    102112} 
  • branches/1.1/lib/task/sfBaseTask.class.php

    r7401 r7614  
    1919abstract class sfBaseTask extends sfCommandApplicationTask 
    2020{ 
     21  protected 
     22    $configuration = null; 
     23 
    2124  /** 
    2225   * @see sfTask 
     
    2831    $this->checkProjectExists(); 
    2932 
    30     try 
     33    $this->configuration = new sfProjectConfiguration(getcwd()); 
     34 
     35    $application = $commandManager->getArgumentSet()->hasArgument('application') ? $commandManager->getArgumentValue('application') : null; 
     36    if (!is_null($application)) 
    3137    { 
    32       if (!is_null($commandManager->getArgumentValue('application'))) 
    33       { 
    34         $this->checkAppExists($commandManager->getArgumentValue('application')); 
    35       } 
    36     } 
    37     catch (sfCommandException $e) 
    38     { 
     38      $this->checkAppExists($application); 
     39      $class = $application.'Configuration'; 
     40      require_once sfConfig::get('sf_lib_dir').'/'.$class.'.class.php'; 
     41      $this->configuration = new $class('test', true); 
    3942    } 
    4043 
     
    6265 
    6366    return $this->filesystem; 
    64   } 
    65  
    66   /** 
    67    * Bootstraps a symfony application. 
    68    * 
    69    * @param string  The application name 
    70    * @param string  The environment name 
    71    * @param Boolean Whether to bootstrap the symfony application in debug mode 
    72    */ 
    73   public function bootstrapSymfony($app, $env = 'dev', $debug = true) 
    74   { 
    75     if (defined('SF_ROOT_DIR')) 
    76     { 
    77       return; 
    78     } 
    79  
    80     define('SF_ROOT_DIR',    sfConfig::get('sf_root_dir')); 
    81     define('SF_APP',         $app); 
    82     define('SF_ENVIRONMENT', $env); 
    83     define('SF_DEBUG',       $debug); 
    84  
    85     require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    86  
    87     sfContext::getInstance(); 
    8867  } 
    8968 
  • branches/1.1/lib/util/sfBrowser.class.php

    r6867 r7614  
    219219    } 
    220220 
     221    ob_start(); 
     222 
    221223    // recycle our context object 
    222     $this->context = sfContext::getInstance(); 
    223     $this->context->initialize(); 
    224     $this->context->getEventDispatcher()->connect('application.throw_exception', array($this, 'ListenToException')); 
     224    $this->context = $this->getContext(true); 
    225225 
    226226    // launch request via controller 
     
    235235 
    236236    // dispatch our request 
    237     ob_start(); 
    238237    $controller->dispatch(); 
     238 
    239239    $retval = ob_get_clean(); 
    240240 
     
    369369 
    370370  /** 
    371    * Gets context. 
     371   * Returns the current application context. 
     372   * 
     373   * @param  Boolean true to force context reload, false otherwise 
    372374   * 
    373375   * @return sfContext 
    374376   */ 
    375   public function getContext() 
    376   { 
     377  public function getContext($forceReload = false) 
     378  { 
     379    if (is_null($this->context) || $forceReload) 
     380    { 
     381      $this->context = sfContext::getInstance(); 
     382      $this->context->initialize($this->context->getConfiguration()); 
     383      $this->context->getEventDispatcher()->connect('application.throw_exception', array($this, 'ListenToException')); 
     384    } 
     385 
    377386    return $this->context; 
    378387  } 
  • branches/1.1/lib/util/sfContext.class.php

    r7140 r7614  
    2424{ 
    2525  protected 
    26     $dispatcher = null, 
    27     $factories  = array(); 
     26    $dispatcher    = null, 
     27    $configuration = null, 
     28    $factories     = array(); 
    2829 
    2930  protected static 
     
    3233 
    3334  /** 
    34    * Initializes the current sfContext instance. 
    35    */ 
    36   public function initialize() 
    37   { 
    38     $this->dispatcher = new sfEventDispatcher(); 
    39  
    40     if (sfConfig::get('sf_use_database')) 
    41     { 
    42       // setup our database connections 
    43       $this->factories['databaseManager'] = new sfDatabaseManager(array('auto_shutdown' => false)); 
    44     } 
    45  
    46     // create a new action stack 
    47     $this->factories['actionStack'] = new sfActionStack(); 
    48  
    49     try 
    50     { 
    51       // include the factories configuration 
    52       require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/factories.yml')); 
    53     } 
    54     catch (sfException $e) 
    55     { 
    56       $e->printStackTrace(); 
    57     } 
    58     catch (Exception $e) 
    59     { 
    60       sfException::createFromException($e)->printStackTrace(); 
    61     } 
    62  
    63     if (sfConfig::get('sf_logging_enabled')) 
    64     { 
    65       $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Initialization'))); 
    66     } 
    67  
    68     $this->dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters')); 
    69  
    70     // register our shutdown function 
    71     register_shutdown_function(array($this, 'shutdown')); 
    72   } 
    73  
    74   /** 
    75    * Retrieves the singleton instance of this class. 
    76    * 
    77    * @param  string    The name of the sfContext to retrieve. 
    78    * 
    79    * @return sfContext A sfContext implementation instance. 
    80    */ 
    81   public static function getInstance($name = null, $class = __CLASS__) 
     35   * Creates a new context instance. 
     36   * 
     37   * @param  sfApplicationConfiguration A sfApplicationConfiguration instance 
     38   * @param  string                     A name for this context (application name by default) 
     39   * @param  string                     The context class to use (sfContext by default) 
     40   * 
     41   * @return sfContext                  A sfContext instance 
     42   */ 
     43  static public function createInstance(sfApplicationConfiguration $configuration, $name = null, $class = __CLASS__) 
    8244  { 
    8345    if (is_null($name)) 
    8446    { 
    85       $name = self::$current; 
    86     } 
     47      $name = $configuration->getApplication(); 
     48    } 
     49 
     50    self::$current = $name; 
    8751 
    8852    if (!isset(self::$instances[$name])) 
     
    9559      } 
    9660 
    97       self::$instances[$name]->initialize(); 
     61      self::$instances[$name]->initialize($configuration); 
    9862    } 
    9963 
     
    10266 
    10367  /** 
     68   * Initializes the current sfContext instance. 
     69   * 
     70   * @param sfApplicationConfiguration A sfApplicationConfiguration instance 
     71   */ 
     72  public function initialize(sfApplicationConfiguration $configuration) 
     73  { 
     74    $this->configuration = $configuration; 
     75    $this->dispatcher    = $configuration->getEventDispatcher(); 
     76 
     77    try 
     78    { 
     79      $this->loadFactories(); 
     80    } 
     81    catch (sfException $e) 
     82    { 
     83      $e->printStackTrace(); 
     84    } 
     85    catch (Exception $e) 
     86    { 
     87      sfException::createFromException($e)->printStackTrace(); 
     88    } 
     89 
     90    if (sfConfig::get('sf_logging_enabled')) 
     91    { 
     92      $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Initialization'))); 
     93    } 
     94 
     95    $this->dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters')); 
     96 
     97    // register our shutdown function 
     98    register_shutdown_function(array($this, 'shutdown')); 
     99  } 
     100 
     101  /** 
     102   * Retrieves the singleton instance of this class. 
     103   * 
     104   * @param  string    The name of the sfContext to retrieve. 
     105   * 
     106   * @return sfContext A sfContext implementation instance. 
     107   */ 
     108  static public function getInstance($name = null, $class = __CLASS__) 
     109  { 
     110    if (is_null($name)) 
     111    { 
     112      $name = self::$current; 
     113    } 
     114 
     115    if (!isset(self::$instances[$name])) 
     116    { 
     117      throw new sfException(sprintf('The "%s" context does not exist.', $name)); 
     118    } 
     119 
     120    return self::$instances[$name]; 
     121  } 
     122 
     123  /** 
    104124   * Checks to see if there has been a context created 
    105125   * 
    106    * @param  string    The name of the sfContext to check for 
     126   * @param  string   The name of the sfContext to check for 
    107127   * 
    108128   * @return boolean  True is instanced, otherwise false 
     
    120140 
    121141  /** 
    122    * 
     142   * Loads the symfony factories. 
     143   */ 
     144  public function loadFactories() 
     145  { 
     146    if (sfConfig::get('sf_use_database')) 
     147    { 
     148      // setup our database connections 
     149      $this->factories['databaseManager'] = new sfDatabaseManager($this->configuration, array('auto_shutdown' => false)); 
     150    } 
     151 
     152    // create a new action stack 
     153    $this->factories['actionStack'] = new sfActionStack(); 
     154 
     155    // include the factories configuration 
     156    require($this->configuration->getConfigCache()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/factories.yml')); 
     157 
     158    $this->dispatcher->notify(new sfEvent($this, 'context.load_factories')); 
     159  } 
     160 
     161  /** 
     162   * Dispatches the current request. 
     163   */ 
     164  public function dispatch() 
     165  { 
     166    $this->getController()->dispatch(); 
     167  } 
     168 
     169  /** 
    123170   * Sets the current context to something else 
    124171   * 
     
    129176  { 
    130177    self::$current = $name; 
     178  } 
     179 
     180  /** 
     181   * Returns the configuration instance. 
     182   * 
     183   * @return sfConfiguration The sfConfiguration instance 
     184   */ 
     185  public function getConfiguration() 
     186  { 
     187    return $this->configuration; 
    131188  } 
    132189 
     
    346403 
    347404  /** 
     405   * Returns the configuration cache. 
     406   * 
     407   * @return sfConfigCache A sfConfigCache instance 
     408   */ 
     409  public function getConfigCache() 
     410  { 
     411    return $this->configuration->getConfigCache(); 
     412  } 
     413 
     414  /** 
    348415   * Gets an object from the current context. 
    349416   * 
  • branches/1.1/lib/view/sfPHPView.class.php

    r7407 r7614  
    104104 
    105105    // require our configuration 
    106     $viewConfigFile = $this->moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/view.yml'; 
    107     require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$viewConfigFile)); 
     106    require($this->context->getConfigCache()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$this->moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/view.yml')); 
    108107 
    109108    // decorator configuration 
     
    113112    if (!$this->directory) 
    114113    { 
    115       $this->setDirectory(sfLoader::getTemplateDir($this->moduleName, $this->getTemplate())); 
     114      $this->setDirectory($this->context->getConfiguration()->getTemplateDir($this->moduleName, $this->getTemplate())); 
    116115    } 
    117116  } 
  • branches/1.1/lib/view/sfPartialView.class.php

    r7407 r7614  
    4040    else 
    4141    { 
    42       $this->setDirectory(sfLoader::getTemplateDir($this->moduleName, $this->getTemplate())); 
     42      $this->setDirectory($this->context->getConfiguration()->getTemplateDir($this->moduleName, $this->getTemplate())); 
    4343    } 
    4444  } 
  • branches/1.1/lib/view/sfViewCacheManager.class.php

    r6509 r7614  
    194194    if (!isset($this->loaded[$moduleName])) 
    195195    { 
    196       require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/cache.yml')); 
     196      require($this->context->getConfigCache()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/cache.yml')); 
    197197      $this->loaded[$moduleName] = true; 
    198198    } 
  • branches/1.1/test/bin/loc.php

    r7370 r7614  
    55require_once($root_dir.'/lib/util/sfFinder.class.php'); 
    66 
    7 require_once($root_dir.'/lib/util/sfCoreAutoload.class.php'); 
    8 require_once($root_dir.'/lib/util/sfCore.class.php'); 
     7require_once($root_dir.'/lib/autoload/sfCoreAutoload.class.php'); 
    98$version = SYMFONY_VERSION; 
    109 
  • branches/1.1/test/bootstrap/functional.php

    r6870 r7614  
    2121  $root_dir = realpath(dirname(__FILE__).sprintf('/../%s/fixtures/project', isset($type) ? $type : 'functional')); 
    2222} 
    23 define('SF_ROOT_DIR',    $root_dir); 
    24 define('SF_APP',         $app); 
    25 define('SF_ENVIRONMENT', 'test'); 
    26 define('SF_DEBUG',       isset($debug) ? $debug : true); 
    2723 
    28 // initialize symfony 
    29 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
     24$class = $app.'Configuration'; 
     25require $root_dir.'/lib/'.$class.'.class.php'; 
     26$configuration = new $class('test', isset($debug) ? $debug : true); 
     27sfContext::createInstance($configuration); 
    3028 
    3129// remove all cache 
  • branches/1.1/test/functional/fixtures/project/symfony

    r7433 r7614  
    1111 
    1212chdir(dirname(__FILE__)); 
    13 include('config/config.php'); 
    14 include($sf_symfony_lib_dir.'/command/cli.php'); 
     13require_once(dirname(__FILE__).'/lib/ProjectConfiguration.class.php'); 
     14$configuration = new ProjectConfiguration(); 
     15include($configuration->getSymfonyLibDir().'/command/cli.php'); 
  • branches/1.1/test/functional/fixtures/project/test/bootstrap/functional.php

    r5260 r7614  
    44 * This file is part of the symfony package. 
    55 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    6  *  
     6 * 
    77 * For the full copyright and license information, please view the LICENSE 
    88 * file that was distributed with this source code. 
     
    1414  $traces = debug_backtrace(); 
    1515  $caller = $traces[0]; 
    16   $app = array_pop(explode(DIRECTORY_SEPARATOR, dirname($caller['file']))); 
     16 
     17  $dirPieces = explode(DIRECTORY_SEPARATOR, dirname($caller['file'])); 
     18  $app = array_pop($dirPieces); 
    1719} 
    1820 
    19 // define symfony constant 
    20 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/../..')); 
    21 define('SF_APP',         $app); 
    22 define('SF_ENVIRONMENT', 'test'); 
    23 define('SF_DEBUG',       true); 
     21$class = $app.'Configuration'; 
     22require_once(dirname(__FILE__).'/../../lib/'.$class.'.class.php'); 
    2423 
    25 // initialize symfony 
    26 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
     24$configuration = new $class('test', true); 
     25sfContext::createInstance($configuration); 
    2726 
    2827// remove all cache 
  • branches/1.1/test/functional/fixtures/project/test/bootstrap/unit.php

    r2543 r7614  
    1010 
    1111$_test_dir = realpath(dirname(__FILE__).'/..'); 
    12 define('SF_ROOT_DIR', realpath($_test_dir.'/..')); 
    1312 
    14 // symfony directories 
    15 include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    16  
    17 require_once($sf_symfony_lib_dir.'/vendor/lime/lime.php'); 
     13require_once(dirname(__FILE__).'/../../lib/ProjectConfiguration.class.php'); 
     14$configuration = new ProjectConfiguration(realpath($_test_dir.'/..')); 
     15include($configuration->getSymfonyLibDir().'/vendor/lime/lime.php'); 
  • branches/1.1/test/functional/fixtures/project/web/cache.php

    r2369 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'cache'); 
    5 define('SF_ENVIRONMENT', 'prod'); 
    6 define('SF_DEBUG',       false); 
     3require_once(dirname(__FILE__).'/../lib/cacheConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new cacheConfiguration('prod', false); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/test/functional/fixtures/project/web/cache_dev.php

    r2369 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'cache'); 
    5 define('SF_ENVIRONMENT', 'dev'); 
    6 define('SF_DEBUG',       true); 
     3require_once(dirname(__FILE__).'/../lib/cacheConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new cacheConfiguration('dev', true); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/test/functional/fixtures/project/web/frontend_dev.php

    r2369 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'frontend'); 
    5 define('SF_ENVIRONMENT', 'dev'); 
    6 define('SF_DEBUG',       true); 
     3require_once(dirname(__FILE__).'/../lib/frontendConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new frontendConfiguration('dev', true); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/test/functional/fixtures/project/web/i18n.php

    r2740 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'i18n'); 
    5 define('SF_ENVIRONMENT', 'prod'); 
    6 define('SF_DEBUG',       false); 
     3require_once(dirname(__FILE__).'/../lib/i18nConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new i18nConfiguration('prod', false); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/test/functional/fixtures/project/web/i18n_dev.php

    r2740 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'i18n'); 
    5 define('SF_ENVIRONMENT', 'dev'); 
    6 define('SF_DEBUG',       true); 
     3require_once(dirname(__FILE__).'/../lib/i18nConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new i18nConfiguration('dev', true); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/test/functional/fixtures/project/web/index.php

    r2369 r7614  
    11<?php 
    22 
    3 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
    4 define('SF_APP',         'frontend'); 
    5 define('SF_ENVIRONMENT', 'prod'); 
    6 define('SF_DEBUG',       false); 
     3require_once(dirname(__FILE__).'/../lib/frontendConfiguration.class.php'); 
    74 
    8 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    9  
    10 sfContext::getInstance()->getController()->dispatch(); 
     5$configuration = new frontendConfiguration('prod', false); 
     6sfContext::createInstance($configuration)->dispatch(); 
  • branches/1.1/test/other/tasksTest.php

    r7332 r7614  
    121121 
    122122$content = $c->execute_command(sprintf('project:freeze %s', realpath(dirname(__FILE__).'/../../data'))); 
    123 $t->like(file_get_contents($c->tmp_dir.DS.'config'.DS.'config.php'), '/dirname\(__FILE__\)/', '"project:freeze" freezes symfony lib and data dir into the project directory'); 
     123$t->like(file_get_contents($c->tmp_dir.DS.'lib'.DS.'ProjectConfiguration.class.php'), '/dirname\(__FILE__\)/', '"project:freeze" freezes symfony lib and data dir into the project directory'); 
    124124 
    125125$content = $c->execute_command('project:unfreeze'); 
    126 $t->unlike(file_get_contents($c->tmp_dir.DS.'config'.DS.'config.php'), '/dirname\(__FILE__\)/', '"project:unfreeze" unfreezes symfony lib and data dir'); 
     126$t->unlike(file_get_contents($c->tmp_dir.DS.'lib'.DS.'ProjectConfiguration.class.php'), '/dirname\(__FILE__\)/', '"project:unfreeze" unfreezes symfony lib and data dir'); 
    127127 
    128128$c->shutdown(); 
  • branches/1.1/test/unit/config/sfConfigCacheTest.php

    r3703 r7614  
    1010 
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    12  
    13 $t = new lime_test(2, new lime_output_color()); 
    14  
    15 // ->getInstance() 
    16 $t->diag('->getInstance()'); 
    17 $t->isa_ok(sfConfigCache::getInstance(), 'sfConfigCache', '::getInstance() returns a sfConfigCache instance'); 
    18 $t->is(sfConfigCache::getInstance(), sfConfigCache::getInstance(), '::getInstance() is a singleton'); 
  • branches/1.1/test/unit/generator/sfGeneratorTest.php

    r4957 r7614  
    1818} 
    1919 
    20 $manager = new sfGeneratorManager(); 
     20class ProjectConfiguration extends sfProjectConfiguration 
     21
     22
     23 
     24$manager = new sfGeneratorManager(new ProjectConfiguration()); 
    2125$generator = new myGenerator($manager); 
  • branches/1.1/test/unit/i18n/extract/sfI18nExtractTest.php

    r7430 r7614  
    1313$t = new lime_test(3, new lime_output_color()); 
    1414 
    15 class sfLoader 
     15class ProjectConfiguration extends sfProjectConfiguration 
    1616{ 
    17   static public function getI18NGlobalDirs() 
     17
     18 
     19class TestConfiguration extends sfApplicationConfiguration 
     20
     21  public function getI18NGlobalDirs() 
    1822  { 
    1923    return array(dirname(__FILE__).'/../fixtures'); 
     
    2125} 
    2226 
    23 $dispatcher = new sfEventDispatcher(); 
     27$configuration = new TestConfiguration('test', true); 
    2428$cache = new sfNoCache(); 
    25 $i18n = new sfI18N($dispatcher, $cache); 
     29$i18n = new sfI18N($configuration, $cache); 
    2630 
    2731class sfI18nExtractTest extends sfI18nExtract 
  • branches/1.1/test/unit/i18n/sfI18NTest.php

    r6684 r7614  
    1313$t = new lime_test(19, new lime_output_color()); 
    1414 
    15 class sfLoader 
     15class ProjectConfiguration extends sfProjectConfiguration 
    1616{ 
    17   static public function getI18NGlobalDirs() 
     17
     18 
     19class TestConfiguration extends sfApplicationConfiguration 
     20
     21  public function getI18NGlobalDirs() 
    1822  { 
    1923    return array(dirname(__FILE__).'/fixtures'); 
     
    2125} 
    2226 
    23 $dispatcher = new sfEventDispatcher(); 
     27$configuration = new TestConfiguration('test', true); 
     28$dispatcher = $configuration->getEventDispatcher(); 
    2429$cache = new sfNoCache(); 
    2530 
    2631// ->initialize() 
    2732$t->diag('->initialize()'); 
    28 $i18n = new sfI18N($dispatcher, $cache); 
     33$i18n = new sfI18N($configuration, $cache); 
    2934$dispatcher->notify(new sfEvent(null, 'user.change_culture', array('culture' => 'fr'))); 
    3035$t->is($i18n->getCulture(), 'fr', '->initialize() connects to the user.change_culture event'); 
     
    3237// ->getCulture() ->setCulture() 
    3338$t->diag('->getCulture() ->setCulture()'); 
    34 $i18n = new sfI18N($dispatcher, $cache); 
     39$i18n = new sfI18N($configuration, $cache); 
    3540$t->is($i18n->getCulture(), 'en', '->getCulture() returns the current culture'); 
    3641$i18n->setCulture('fr'); 
     
    4045$t->diag('->__()'); 
    4146sfConfig::set('sf_charset', 'UTF-8'); 
    42 $i18n = new sfI18N($dispatcher, $cache, array('culture' => 'fr')); 
     47$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); 
    4348$t->is($i18n->__('an english sentence'), 'une phrase en français', '->__() translates a string'); 
    4449$args = array('%timestamp%' => $timestamp = time()); 
     
    5055 
    5156// debug 
    52 $i18n = new sfI18N($dispatcher, $cache, array('debug' => true)); 
     57$i18n = new sfI18N($configuration, $cache, array('debug' => true)); 
    5358$t->is($i18n->__('unknown'), '[T]unknown[/T]', '->__() adds a prefix and a suffix on untranslated strings if debug is on'); 
    54 $i18n = new sfI18N($dispatcher, $cache, array('debug' => true, 'untranslated_prefix' => '-', 'untranslated_suffix' => '#')); 
     59$i18n = new sfI18N($configuration, $cache, array('debug' => true, 'untranslated_prefix' => '-', 'untranslated_suffix' => '#')); 
    5560$t->is($i18n->__('unknown'), '-unknown#', '->initialize() can change the default prefix and suffix dor untranslated strings'); 
    5661 
    5762// ->getCountry() 
    5863$t->diag('->getCountry()'); 
    59 $i18n = new sfI18N($dispatcher, $cache, array('culture' => 'fr')); 
     64$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); 
    6065$t->is($i18n->getCountry('FR'), 'France', '->getCountry() returns the name of a country for the current culture'); 
    6166$t->is($i18n->getCountry('FR', 'es'), 'Francia', '->getCountry() takes an optional culture as its second argument'); 
     
    6368// ->getNativeName() 
    6469$t->diag('->getNativeName()'); 
    65 $i18n = new sfI18N($dispatcher, $cache, array('culture' => 'fr')); 
     70$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); 
    6671$t->is($i18n->getNativeName('fr'), 'français', '->getNativeName() returns the name of a culture'); 
    6772 
    6873// ->getTimestampForCulture() 
    6974$t->diag('->getTimestampForCulture()'); 
    70 $i18n = new sfI18N($dispatcher, $cache, array('culture' => 'fr')); 
     75$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); 
    7176$t->is($i18n->getTimestampForCulture('15/10/2005'), mktime(0, 0, 0, '10', '15', '2005'), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture'); 
    7277$t->is($i18n->getTimestampForCulture('10/15/2005', 'en_US'), mktime(0, 0, 0, '10', '15', '2005'), '->getTimestampForCulture() can take a culture as its second argument'); 
     
    7580// ->getDateForCulture() 
    7681$t->diag('->getDateForCulture()'); 
    77 $i18n = new sfI18N($dispatcher, $cache, array('culture' => 'fr')); 
     82$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); 
    7883$t->is($i18n->getDateForCulture('15/10/2005'), array('15', '10', '2005'), '->getDateForCulture() returns the day, month and year for a data formatted in the current culture'); 
    7984$t->is($i18n->getDateForCulture('10/15/2005', 'en_US'), array('15', '10', '2005'), '->getDateForCulture() can take a culture as its second argument'); 
  • branches/1.1/test/unit/task/cache/sfCacheClearTaskTest.php

    r6859 r7614  
    1313$t = new lime_test(2, new lime_output_color()); 
    1414 
     15class ProjectConfiguration extends sfProjectConfiguration 
     16{ 
     17} 
     18 
     19class TestConfiguration extends sfApplicationConfiguration 
     20{ 
     21} 
     22 
     23$configuration = new TestConfiguration('test', true, sfConfig::get('sf_root_dir')); 
    1524$dispatcher = new sfEventDispatcher(); 
    1625$formatter = new sfFormatter(); 
     
    2029$task = new sfGenerateAppTask($dispatcher, $formatter); 
    2130$task->run(array('frontend')); 
    22  
    23 sfCore::initDirectoryLayout(sfConfig::get('sf_root_dir'), 'frontend', 'dev'); 
    2431 
    2532// Put something in the cache 
  • branches/1.1/test/unit/util/sfContextTest.php

    r4449 r7614  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(8, new lime_output_color()); 
     13// FIXME 
     14$t = new lime_test(0, new lime_output_color()); 
    1415 
    1516class myContext extends sfContext 
    1617{ 
    17   public function initialize(
     18  public function initialize(sfApplicationConfiguration $configuration
    1819  { 
    1920  } 
    2021} 
    2122 
     23class ProjectConfiguration extends sfProjectConfiguration 
     24{ 
     25} 
     26 
     27class frontendConfiguration extends sfApplicationConfiguration 
     28{ 
     29} 
     30/* 
    2231// ::getInstance() 
    2332$t->diag('::getInstance()'); 
     
    5261  $t->pass('->get() throws an sfException if no object is stored for the given name'); 
    5362} 
     63*/ 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.