Development

Changeset 7618

You must first sign up to be able to contribute.

Changeset 7618

Show
Ignore:
Timestamp:
02/27/08 01:02:41 (2 years ago)
Author:
dwhittle
Message:

dwhittle: merged new configuration system from r7614

Files:

Legend:

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

    r7522 r7618  
    1313To upgrade a project: 
    1414 
    15   * Upgrade symfony via PEAR or change your `config/config.php` 
    16     to update the symfony directory. 
     15  * If you don't use a SCM tool, please make a backup of your project. 
     16    As symfony replaces some files during the upgrade 
     17    (front controllers for example), you need a way to merge your 
     18    customizations after the upgrade. 
    1719 
    1820  * Update the `symfony` file located in the project root directory 
    19     by changing the line: 
    20  
     21    by changing those three lines: 
     22 
     23        [php] 
     24        chdir(dirname(__FILE__)); 
     25        include('config/config.php'); 
    2126        include($sf_symfony_data_dir.'/bin/symfony.php'); 
    2227 
    2328    to 
    2429 
    25         include($sf_symfony_lib_dir.'/command/cli.php'); 
     30        [php] 
     31        chdir(dirname(__FILE__)); 
     32        require_once(dirname(__FILE__).'/lib/ProjectConfiguration.class.php'); 
     33        $configuration = new ProjectConfiguration(); 
     34        include($configuration->getSymfonyLibDir().'/command/cli.php'); 
     35 
     36    You can also copy the skeleton file from the symfony project skeleton directly: 
     37 
     38        $ cp /path/to/symfony/lib/task/generator/skeleton/project/symfony symfony 
     39 
     40  * Create a `lib/ProjectConfiguration.class.php` file with the following content: 
     41 
     42        [php] 
     43        <?php 
     44 
     45        require_once '##SYMFONY_LIB_DIR##/autoload/sfCoreAutoload.class.php'; 
     46        sfCoreAutoload::register(); 
     47 
     48        class ProjectConfiguration extends sfProjectConfiguration 
     49        { 
     50          public function setup() 
     51          { 
     52          } 
     53        } 
     54 
     55    Then, replace `##SYMFONY_LIB_DIR##` with the path to the symfony 1.1 
     56    `lib/` directory. This is the new way to change the symfony version used 
     57    for your project. 
     58 
     59    You can also copy the skeleton file from the symfony project skeleton directly: 
     60 
     61        $ cp /path/to/symfony/lib/task/generator/skeleton/project/lib/ProjectConfiguration.class.php lib/ProjectConfiguration.class.php 
    2662 
    2763  * Launch the `project:upgrade1.1` task from your project directory 
     
    236272 
    237273The `autoloading_function` setting in `settings.yml` is not used anymore. 
    238 You can register autoloading callables in the application `config.php`. 
    239 Here is the new default `config.php`: 
    240  
    241     [php] 
    242     <?php 
    243  
    244     // include project configuration 
    245     include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    246  
    247     // symfony bootstraping 
    248     require_once($sf_symfony_lib_dir.'/util/sfCore.class.php'); 
    249     sfCore::bootstrap($sf_symfony_lib_dir, $sf_symfony_data_dir); 
    250  
    251     // insert your own autoloading callables here 
    252  
    253     if (sfConfig::get('sf_debug')) 
    254     { 
    255       spl_autoload_register(array('sfAutoload', 'autoloadAgain')); 
    256     } 
     274You can register autoloading callables in your application configuration class. 
    257275 
    258276Thanks to the new `sfAutoload::autoloadAgain()` method, you won't need to clear 
    259277the cache when you add or move classes in your project. This method will 
    260278automatically find the changes and flush the autoloading cache. 
    261  
    262 The `project:upgrade1.1` task makes all those changes for you. 
    263279 
    264280 
     
    504520 `data/exception.*`     | `lib/exception/data` 
    505521 
    506 The symfony core have been upgraded to take these changes into account. 
     522The symfony core has been upgraded to take these changes into account. 
     523 
     524sfLoader 
     525-------- 
     526 
     527All `sfLoader` static methods (except `::getHelperDirs()` and `::loadHelpers()`) 
     528have been moved to the `sfProjectConfiguration` and `sfApplicationConfiguration` 
     529classes: 
     530 
     531  * `sfProjectConfiguration`: 
     532      * `->getGeneratorSkeletonDirs()` 
     533      * `->getGeneratorTemplate()` 
     534      * `->getGeneratorTemplateDirs()` 
     535      * `->getModelDirs()` 
     536 
     537  * `sfApplicationConfiguration`: 
     538      * `->getControllerDirs()` 
     539      * `->getTemplateDirs()` 
     540      * `->getTemplateDir()` 
     541      * `->getTemplatePath()` 
     542      * `->getI18NGlobalDirs()` 
     543      * `->getI18NDirs()` 
     544      * `->getConfigPaths()` 
     545 
     546sfCore 
     547------ 
     548 
     549The `sfCore` has been removed. The code has been moved to `sfProjectConfiguration`, 
     550`sfApplicationConfiguration`, and `sfContext` classes. 
     551 
     552Front Controllers 
     553----------------- 
     554 
     555All front controllers have to be upgraded. The SF_DEBUG, SF_APP, SF_ENVIRONMENT, 
     556and SF_ROOT_DIR constants are gone. If you use some of these constants in your 
     557project, please use their sfConfig::get('') counterparts: 
     558 
     559 *Old*             | *New* 
     560 ----------------- | --------------------------------- 
     561 `SF_ROOT_DIR`     | `sfConfig::get('sf_root_dir')` 
     562 `SF_ENVIRONMENT`  | `sfConfig::get('sf_environment')` 
     563 `SF_APP`          | `sfConfig::get('sf_app')` 
     564 `SF_DEBUG`        | `sfConfig::get('sf_debug')` 
     565 
     566The `project:upgrade1.1` task upgrades all front controllers for you. 
     567If you made some customizations, symfony will issue a warning and won't 
     568upgrade them automatically. You can then copy the default skeleton from 
     569symfony: /path/to/symfony/lib/task/generator/skeleton/app/web/index.php 
     570 
     571config.php 
     572---------- 
     573 
     574All `config.php` files have been removed. The are replaced by the `ProjectConfiguration` 
     575class and the application configuration classes. 
     576 
     577If you've added some cutomizations in `config.php` files, you will have to migrate them 
     578to those new classes. 
  • branches/dwhittle/1.1/lib/action/sfAction.class.php

    r6669 r7618  
    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/dwhittle/1.1/lib/autoload/sfAutoload.class.php

    r7255 r7618  
    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/dwhittle/1.1/lib/autoload/sfCoreAutoload.class.php

    r7454 r7618  
    158158  'sfFormatter' => 'command', 
    159159  'sfSymfonyCommandApplication' => 'command', 
     160  'sfApplicationConfiguration' => 'config', 
    160161  'sfAutoloadConfigHandler' => 'config', 
    161162  'sfCacheConfigHandler' => 'config', 
     
    163164  'sfConfig' => 'config', 
    164165  'sfConfigCache' => 'config', 
    165   'sfConfigDimension' => 'config', 
    166166  'sfConfigHandler' => 'config', 
    167167  'sfDatabaseConfigHandler' => 'config', 
     
    171171  'sfGeneratorConfigHandler' => 'config', 
    172172  'sfLoader' => 'config', 
     173  'sfProjectConfiguration' => 'config', 
    173174  'sfRootConfigHandler' => 'config', 
    174175  'sfRoutingConfigHandler' => 'config', 
     
    322323  'sfProjectUnfreezeTask' => 'task/project', 
    323324  'sfUpgradeTo11Task' => 'task/project', 
    324   'sfAutoloadingUpgrade' => 'task/project/upgrade1.1', 
    325325  'sfComponentUpgrade' => 'task/project/upgrade1.1', 
    326326  'sfConfigFileUpgrade' => 'task/project/upgrade1.1', 
     
    333333  'sfRenderingFilterUpgrade' => 'task/project/upgrade1.1', 
    334334  'sfSingletonUpgrade' => 'task/project/upgrade1.1', 
     335  'sfTestUpgrade' => 'task/project/upgrade1.1', 
    335336  'sfUpgrade' => 'task/project/upgrade1.1', 
    336337  'sfWebDebugUpgrade' => 'task/project/upgrade1.1', 
     
    346347  'sfSecurityUser' => 'user', 
    347348  'sfUser' => 'user', 
    348   'CartesianIterator' => 'util', 
    349349  'sfBrowser' => 'util', 
    350350  'sfCallable' => 'util', 
    351351  'sfContext' => 'util', 
    352   'sfCore' => 'util', 
    353352  'sfDomCssSelector' => 'util', 
    354353  'sfFinder' => 'util', 
  • branches/dwhittle/1.1/lib/command/cli.php

    r7349 r7618  
    1616  $dispatcher = new sfEventDispatcher(); 
    1717  $logger = new sfCommandLogger($dispatcher); 
    18   $options = array('symfony_lib_dir' => realpath(dirname(__FILE__).'/..')); 
    1918 
    20   $application = new sfSymfonyCommandApplication($dispatcher, new sfAnsiColorFormatter(), $options); 
     19  $application = new sfSymfonyCommandApplication($dispatcher, new sfAnsiColorFormatter(), array('symfony_lib_dir' => realpath(dirname(__FILE__).'/..'))); 
    2120  $application->run(); 
    2221} 
  • branches/dwhittle/1.1/lib/command/sfSymfonyCommandApplication.class.php

    r7469 r7618  
    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/dwhittle/1.1/lib/config/config/core_compile.yml

    r7310 r7618  
    1 # symfony prereqs - always manually included in sfCore::bootstrap 
    2 #- %SF_SYMFONY_LIB_DIR%/config/sfConfig.class.php 
    3 #- %SF_SYMFONY_LIB_DIR%/config/sfLoader.class.php 
    4 #- %SF_SYMFONY_LIB_DIR%/util/sfContext.class.php 
    5 #- %SF_SYMFONY_LIB_DIR%/util/sfParameterHolder.class.php 
    6 #- %SF_SYMFONY_LIB_DIR%/cache/sfCache.class.php 
     1# symfony prereqs 
    72 
    83# symfony core classes 
     
    1712- %SF_SYMFONY_LIB_DIR%/database/sfDatabase.class.php 
    1813- %SF_SYMFONY_LIB_DIR%/database/sfDatabaseManager.class.php 
    19 - %SF_SYMFONY_LIB_DIR%/event/sfEvent.class.php 
    20 - %SF_SYMFONY_LIB_DIR%/event/sfEventDispatcher.class.php 
    2114- %SF_SYMFONY_LIB_DIR%/filter/sfFilter.class.php 
    2215- %SF_SYMFONY_LIB_DIR%/filter/sfFilterChain.class.php 
  • branches/dwhittle/1.1/lib/config/sfApplicationConfiguration.class.php

    r7614 r7618  
    186186  { 
    187187    // recent symfony update? 
    188     if (SYMFONY_VERSION != @file_get_contents(sfConfig::get('sf_config_cache_dir').'/VERSION')) 
     188    if (!sfConfig::get('sf_debug') && !sfConfig::get('sf_test') && (SYMFONY_VERSION != @file_get_contents(sfConfig::get('sf_config_cache_dir').DIRECTORY_SEPARATOR.'VERSION'))) 
    189189    { 
    190190      // clear cache 
  • branches/dwhittle/1.1/lib/config/sfCompileConfigHandler.class.php

    r7377 r7618  
    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/dwhittle/1.1/lib/config/sfConfigCache.class.php

    r7454 r7618  
    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/dwhittle/1.1/lib/config/sfFactoryConfigHandler.class.php

    r7524 r7618  
    148148          if (isset($parameters['cache'])) 
    149149          { 
    150             $instances[] = sprintf("    \$cache = new %s(%s);\n", $parameters['cache']['class'], var_export($parameters['cache']['param'], true)); 
     150            $cache = sprintf("    \$cache = new %s(%s);\n", $parameters['cache']['class'], var_export($parameters['cache']['param'], true)); 
    151151            unset($parameters['cache']); 
    152152          } 
    153153          else 
    154154          { 
    155             $instances[] = "    \$cache = \$this->factories['cache'];\n"; 
     155            $cache = "    \$cache = \$this->factories['cache'];\n"; 
    156156          } 
    157157 
    158158          $instances[] = sprintf("\n  if (sfConfig::get('sf_i18n'))\n  {\n". 
    159159                     "    \$class = sfConfig::get('sf_factory_i18n', '%s');\n". 
    160                      "    \$this->factories['i18n'] = new \$class(\$this->dispatcher, array_merge(array('cache' => \$cache), %s));\n". 
     160                     "%s". 
     161                     "    \$this->factories['i18n'] = new \$class(\$this->configuration, \$cache, %s);\n". 
    161162                     "  }\n" 
    162                      , $class, var_export($parameters, true) 
     163                     , $class, $cache, var_export($parameters, true) 
    163164                     ); 
    164165          break; 
  • branches/dwhittle/1.1/lib/config/sfGeneratorConfigHandler.class.php

    r6471 r7618  
    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/dwhittle/1.1/lib/config/sfLoader.class.php

    r7314 r7618  
    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').DIRECTORY_SEPARATOR.'model' ? sfConfig::get('sf_lib_dir').DIRECTORY_SEPARATOR.'model' : 'lib'.DIRECTORY_SEPARATOR.'model');  // project 
    29     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'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.DIRECTORY_SEPARATOR.sfConfig::get('sf_app_module_action_dir_name'); 
    47  
    48     $sf_app_module_dir = sfConfig::get('sf_app_module_dir'); 
    49  
    50     foreach(sfConfig::get('sf_dimension_cascade', array()) as $sf_dimension_dir_name) 
    51     { 
    52       $dirs[$sf_app_module_dir.DIRECTORY_SEPARATOR.$suffix.DIRECTORY_SEPARATOR.$sf_dimension_dir_name] = false;      // application (dimensions) 
    53     } 
    54  
    55     $dirs[$sf_app_module_dir.DIRECTORY_SEPARATOR.$suffix] = false;                                                   // application 
    56  
    57     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.$suffix)) 
    58     { 
    59       $dirs = array_merge($dirs, array_combine($pluginDirs, array_fill(0, count($pluginDirs), true)));               // plugins modules 
    60     } 
    61  
    62     $dirs[sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'controller'.DIRECTORY_SEPARATOR.$suffix] = true;    // core modules 
    63  
    64     return $dirs; 
    65   } 
    66  
    67   /** 
    68    * Gets directories where template files are stored for a given module. 
    69    * 
    70    * @param string The module name 
    71    * 
    72    * @return array An array of directories 
    73    */ 
    74   static public function getTemplateDirs($moduleName) 
    75   { 
    76     $suffix = $moduleName.DIRECTORY_SEPARATOR.sfConfig::get('sf_app_module_template_dir_name'); 
    77  
    78     $sf_app_module_dir = sfConfig::get('sf_app_module_dir'); 
    79  
    80     $dirs = array(); 
    81  
    82     foreach(sfConfig::get('sf_dimension_cascade', array()) as $sf_dimension_dir_name) 
    83     { 
    84       $dirs[] = $sf_app_module_dir.DIRECTORY_SEPARATOR.$suffix.DIRECTORY_SEPARATOR.$sf_dimension_dir_name;      // application (dimensions) 
    85     } 
    86  
    87     $dirs[] = $sf_app_module_dir.DIRECTORY_SEPARATOR.$suffix;                                                   // application 
    88  
    89     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.$suffix)) 
    90     { 
    91       $dirs = array_merge($dirs, $pluginDirs);                                                                  // plugins 
    92     } 
    93  
    94  
    95     $dirs[] = sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'controller'.DIRECTORY_SEPARATOR.$suffix; // core modules 
    96     $dirs[] = sfConfig::get('sf_module_cache_dir').DIRECTORY_SEPARATOR.'auto'.ucfirst($suffix);                 // generated templates in cache 
    97  
    98     return $dirs; 
    99   } 
    100  
    101   /** 
    102    * Gets the template directory to use for a given module and template file. 
    103    * 
    104    * @param string The module name 
    105    * @param string The template file 
    106    * 
    107    * @return string A template directory 
    108    */ 
    109   static public function getTemplateDir($moduleName, $templateFile) 
    110   { 
    111     $dirs = self::getTemplateDirs($moduleName); 
    112     foreach ($dirs as $dir) 
    113     { 
    114       if (is_readable($dir.DIRECTORY_SEPARATOR.$templateFile)) 
    115       { 
    116         return $dir; 
    117       } 
    118     } 
    119  
    120     return null; 
    121   } 
    122  
    123   /** 
    124    * Gets the template to use for a given module and template file. 
    125    * 
    126    * @param string The module name 
    127    * @param string The template file 
    128    * 
    129    * @return string A template path 
    130    */ 
    131   static public function getTemplatePath($moduleName, $templateFile) 
    132   { 
    133     $dir = self::getTemplateDir($moduleName, $templateFile); 
    134  
    135     return $dir ? $dir.DIRECTORY_SEPARATOR.$templateFile : null; 
    136   } 
    137  
    138   /** 
    139    * Gets the i18n directories to use globally. 
    140    * 
    141    * @return array An array of i18n directories 
    142    */ 
    143   static public function getI18NGlobalDirs() 
    144   { 
    145     $dirs = array(); 
    146  
    147     // application 
    148     if (is_dir($dir = sfConfig::get('sf_app_dir').DIRECTORY_SEPARATOR.sfConfig::get('sf_app_module_i18n_dir_name'))) 
    149     { 
    150       $dirs[] = $dir; 
    151     } 
    152  
    153     // plugins 
    154     $pluginDirs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.sfConfig::get('sf_app_module_i18n_dir_name')); 
    155     if (isset($pluginDirs[0])) 
    156     { 
    157       $dirs[] = $pluginDirs[0]; 
    158     } 
    159  
    160     return $dirs; 
    161   } 
    162  
    163   /** 
    164    * Gets the i18n directories to use for a given module. 
    165    * 
    166    * @param string The module name 
    167    * 
    168    * @return array An array of i18n directories 
    169    */ 
    170   static public function getI18NDirs($moduleName) 
    171   { 
    172     $dirs = array(); 
    173  
    174     // module 
    175     if (is_dir($dir = sfConfig::get('sf_app_module_dir').DIRECTORY_SEPARATOR.$moduleName.DIRECTORY_SEPARATOR.sfConfig::get('sf_app_module_i18n_dir_name'))) 
    176     { 
    177       $dirs[] = $dir; 
    178     } 
    179  
    180     // application 
    181     if (is_dir($dir = sfConfig::get('sf_app_dir').DIRECTORY_SEPARATOR.sfConfig::get('sf_app_module_i18n_dir_name'))) 
    182     { 
    183       $dirs[] = $dir; 
    184     } 
    185  
    186     // module in plugins 
    187     $pluginDirs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.$moduleName.DIRECTORY_SEPARATOR.sfConfig::get('sf_app_module_i18n_dir_name')); 
    188     if (isset($pluginDirs[0])) 
    189     { 
    190       $dirs[] = $pluginDirs[0]; 
    191     } 
    192  
    193     // plugins 
    194     $pluginDirs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.sfConfig::get('sf_app_module_i18n_dir_name')); 
    195     if (isset($pluginDirs[0])) 
    196     { 
    197       $dirs[] = $pluginDirs[0]; 
    198     } 
    199  
    200     return $dirs; 
    201   } 
    202  
    203   /** 
    204    * Gets directories where template files are stored for a generator class and a specific theme. 
    205    * 
    206    * @param string The generator class name 
    207    * @param string The theme name 
    208    * 
    209    * @return array An array of directories 
    210    */ 
    211   static public function getGeneratorTemplateDirs($class, $theme) 
    212   { 
    213     $dirs = array(); 
    214  
    215     $sf_generator_template_dir = sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$theme.DIRECTORY_SEPARATOR.'template'; 
    216  
    217     foreach(sfConfig::get('sf_dimension_cascade', array()) as $sf_dimension_dir_name) 
    218     { 
    219       $dirs[] = $sf_generator_template_dir.DIRECTORY_SEPARATOR.$sf_dimension_dir_name;                        // project (dimensions) 
    220     } 
    221  
    222     $dirs[] = $sf_generator_template_dir;                                                                     // project 
    223  
    224     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$theme.DIRECTORY_SEPARATOR.'template')) 
    225     { 
    226       $dirs = array_merge($dirs, $pluginDirs);                                                                // plugin 
    227     } 
    228  
    229     if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$theme.DIRECTORY_SEPARATOR.'template')) 
    230     { 
    231       $dirs = array_merge($dirs, $bundledPluginDirs);                                                         // bundled plugin 
    232     } 
    233  
    234     return $dirs; 
    235   } 
    236  
    237   /** 
    238    * Gets directories where the skeleton is stored for a generator class and a specific theme. 
    239    * 
    240    * @param string The generator class name 
    241    * @param string The theme name 
    242    * 
    243    * @return array An array of directories 
    244    */ 
    245   static public function getGeneratorSkeletonDirs($class, $theme) 
    246   { 
    247     $dirs = array(); 
    248  
    249     $sf_generator_skeleton_dir = sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$theme.DIRECTORY_SEPARATOR.'skeleton'; 
    250  
    251     foreach(sfConfig::get('sf_dimension_cascade', array()) as $sf_dimension_dir_name) 
    252     { 
    253       $dirs[] = $sf_generator_skeleton_dir.DIRECTORY_SEPARATOR.$sf_dimension_dir_name;                        // project (dimensions) 
    254     } 
    255  
    256     $dirs[] = $sf_generator_skeleton_dir;                                                                     // project 
    257  
    258     if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$theme.DIRECTORY_SEPARATOR.'skeleton')) 
    259     { 
    260       $dirs = array_merge($dirs, $pluginDirs);                                                                // plugin 
    261     } 
    262  
    263     if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$theme.DIRECTORY_SEPARATOR.'skeleton')) 
    264     { 
    265       $dirs = array_merge($dirs, $bundledPluginDirs);                                                         // bundled plugin 
    266     } 
    267  
    268     return $dirs; 
    269   } 
    270  
    271   /** 
    272    * Gets the template to use for a generator class. 
    273    * 
    274    * @param string The generator class name 
    275    * @param string The theme name 
    276    * @param string The template path 
    277    * 
    278    * @return string A template path 
    279    * 
    280    * @throws sfException 
    281    */ 
    282   static public function getGeneratorTemplate($class, $theme, $path) 
    283   { 
    284     $dirs = self::getGeneratorTemplateDirs($class, $theme); 
    285     foreach ($dirs as $dir) 
    286     { 
    287       if (is_readable($dir.DIRECTORY_SEPARATOR.$path)) 
    288       { 
    289         return $dir.DIRECTORY_SEPARATOR.$path; 
    290       } 
    291     } 
    292  
    293     throw new sfException(sprintf('Unable to load "%s" generator template in: %s.', $path, implode(', ', $dirs))); 
    294   } 
    295  
    296   /** 
    297    * Gets the configuration file paths for a given relative configuration path. 
    298    * 
    299    * @param string The configuration path 
    300    * 
    301    * @return array An array of paths 
    302    */ 
    303   static public function getConfigPaths($configPath) 
    304   { 
    305     $sf_root_dir = sfConfig::get('sf_root_dir'); 
    306     $sf_plugins_dir = sfConfig::get('sf_plugins_dir'); 
    307     $sf_app_dir = sfConfig::get('sf_app_dir'); 
    308  
    309     $configName       = basename($configPath); 
    310     $configDir        = dirname($configPath); 
    311     $globalConfigPath = basename($configDir).DIRECTORY_SEPARATOR.$configName; 
    312  
    313     $files = array( 
    314       sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.$globalConfigPath,              // symfony 
    315     ); 
    316  
    317     if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.$globalConfigPath)) 
    318     { 
    319       $files = array_merge($files, $bundledPluginDirs);                              // bundled plugins 
    320     } 
    321  
    322     if ($pluginDirs = glob($sf_plugins_dir.DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.$globalConfigPath)) 
    323     { 
    324       $files = array_merge($files, $pluginDirs);                                     // plugins 
    325     } 
    326  
    327     if ($pluginDirs = glob($sf_plugins_dir.DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.$configPath)) 
    328     { 
    329       $files = array_merge($files, $pluginDirs);                                     // plugins 
    330     } 
    331  
    332     $files = array_merge($files, array( 
    333       $sf_root_dir.DIRECTORY_SEPARATOR.$globalConfigPath,                            // project 
    334       $sf_root_dir.DIRECTORY_SEPARATOR.$configPath,                                  // project 
    335       $sf_app_dir.DIRECTORY_SEPARATOR.$globalConfigPath,                             // application 
    336       sfConfig::get('sf_app_cache_dir').DIRECTORY_SEPARATOR.$configPath,             // generated modules 
    337     )); 
    338  
    339     $files[] = $sf_app_dir.DIRECTORY_SEPARATOR.$configPath;                          // module 
    340  
    341     $sf_dimension_cascade = array_reverse(sfConfig::get('sf_dimension_cascade', array())); 
    342     foreach($sf_dimension_cascade as $sf_dimension_dir_name) 
    343     { 
    344       $files[] = $sf_app_dir.DIRECTORY_SEPARATOR.$configDir.DIRECTORY_SEPARATOR.$sf_dimension_dir_name.DIRECTORY_SEPARATOR.$configName; // application | module (dimensions) 
    345     } 
    346  
    347     $configs = array(); 
    348     foreach (array_unique($files) as $file) 
    349     { 
    350       if (is_readable($file)) 
    351       { 
    352         $configs[] = $file; 
    353       } 
    354     } 
    355  
    356     return $configs; 
    357   } 
    358  
    35921  /** 
    36022   * Gets the helper directories for a given module name. 
     
    448110    } 
    449111  } 
    450  
    451   /** 
    452    * Loads config.php files from plugins 
    453    * 
    454    * @return void 
    455    */ 
    456   static public function loadPluginConfig() 
    457   { 
    458     if ($pluginConfigs = glob(sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php')) 
    459     { 
    460       foreach($pluginConfigs as $config) 
    461       { 
    462         require_once($config); 
    463       } 
    464     } 
    465  
    466     if ($pluginConfigs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php')) 
    467     { 
    468       foreach ($pluginConfigs as $config) 
    469       { 
    470         require_once($config); 
    471       } 
    472     } 
    473   } 
    474112} 
  • branches/dwhittle/1.1/lib/controller/default/templates/moduleSuccess.php

    r7349 r7618  
    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/dwhittle/1.1/lib/controller/sfController.class.php

    r7513 r7618  
    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_once(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/dwhittle/1.1/lib/database/sfDatabaseManager.class.php

    r7454 r7618  
    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/dwhittle/1.1/lib/filter/sfFilterChain.class.php

    r6506 r7618  
    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/dwhittle/1.1/lib/generator/sfCrudGenerator.class.php

    r7490 r7618  
    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/dwhittle/1.1/lib/generator/sfGenerator.class.php

    r6159 r7618  
    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/dwhittle/1.1/lib/generator/sfGeneratorManager.class.php

    r4963 r7618  
    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/dwhittle/1.1/lib/i18n/extract/sfI18nModuleExtract.class.php

    r4397 r7618  
    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/dwhittle/1.1/lib/i18n/sfI18N.class.php

    r7524 r7618  
    2020{ 
    2121  protected 
     22    $configuration = null, 
    2223    $dispatcher    = null, 
    2324    $cache         = null, 
     
    3233   * @see initialize() 
    3334   */ 
    34   public function __construct(sfEventDispatcher $dispatcher, $options = array()) 
    35   { 
    36     $this->initialize($dispatcher, $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, $options = array()) 
    47   { 
    48     $this->dispatcher = $dispatcher; 
    49  
    50     if(isset($options['cache']) && ($options['cache'] instanceof sfCache)) 
    51     { 
    52       $this->cache = $options['cache']; 
    53     } 
     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; 
    5452 
    5553    if (isset($options['culture'])) 
     
    6765    ), $options); 
    6866 
    69     $dispatcher->connect('user.change_culture', array($this, 'listenToChangeCultureEvent')); 
    70     $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; 
    7179  } 
    7280 
     
    155163    if (!isset($this->messageSource)) 
    156164    { 
    157       $this->setMessageSource(sfLoader::getI18NGlobalDirs(), $this->culture); 
     165      $this->setMessageSource($this->configuration->getI18NGlobalDirs(), $this->culture); 
    158166    } 
    159167 
     
    321329  { 
    322330    // change message source directory to our module 
    323     $this->setMessageSource(sfLoader::getI18NDirs($event['module'])); 
     331    $this->setMessageSource($this->configuration->getI18NDirs($event['module'])); 
    324332  } 
    325333} 
  • branches/dwhittle/1.1/lib/log/sfWebDebugLogger.class.php

    r6734 r7618  
    5050    { 
    5151      $this->xdebugLogging = $options['xdebug_logging']; 
     52      ini_set('memory_limit', '256M'); // xdebug can consume a lot of memory 
    5253    } 
    5354 
     
    9596    } 
    9697 
    97     // add needed assets for the web debug toolbar 
     98    // add web debug information to response content 
    9899    $root = $this->context->getRequest()->getRelativeUrlRoot(); 
    99100    $assets = sprintf(' 
     
    103104      $root.sfConfig::get('sf_web_debug_web_dir').'/css/main.css' 
    104105    ); 
    105     $content = str_ireplace('</head>', $assets.'</head>', $content); 
    106106 
    107     // add web debug information to response content 
    108     $webDebugContent = $this->webDebug->getResults(); 
    109     $count = 0; 
    110     $content = str_ireplace('</body>', $webDebugContent.'</body>', $content, $count); 
    111     if (!$count) 
    112     { 
    113       $content .= $webDebugContent; 
    114     } 
     107    $content = str_ireplace('</body>', $this->webDebug->getResults().'</body>', str_ireplace('</head>', $assets.'</head>', $content)); 
    115108 
    116109    return $content; 
     
    132125      { 
    133126        if ( 
    134           (isset($stack['function']) && !in_array($stack['function'], array('emerg', 'alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug', 'log'))) 
     127          (isset($stack['function']) && !in_array($stack['function'], array('emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug', 'log'))) 
    135128          || !isset($stack['function']) 
    136129        ) 
  • branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/config/config.php

    r6745 r7618  
    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/dwhittle/1.1/lib/plugins/sfCompat10Plugin/lib/filter/sfValidationExecutionFilter.class.php

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

    r6669 r7618  
    138138 
    139139  // load component's module config file 
    140   require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml')); 
     140  require(sfContext::getInstance()->getConfigCache()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml')); 
    141141 
    142142  $componentInstance->getVarHolder()->add($vars); 
  • branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/lib/view/sfMailView.class.php

    r5125 r7618  
    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/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/bootstrap/functional.php

    r5386 r7618  
    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/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/symfony

    r7454 r7618  
    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/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/functional.php

    r5321 r7618  
    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/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/unit.php

    r5321 r7618  
    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/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/frontend_dev.php

    r5321 r7618  
    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/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/index.php

    r5321 r7618  
    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/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/unit/validator/sfDateValidatorTest.php

    r7578 r7618  
    1919 
    2020$v = new sfDateValidator($context); 
    21 $v->initialize($context); 
    2221 
    2322// ->execute() 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/config/config.php

    r5174 r7618  
    11<?php 
    22 
    3 set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/../lib/vendor'.PATH_SEPARATOR.dirname(__FILE__).'/../lib/vendor/propel-generator/classes/'); 
     3set_include_path(sfConfig::get('sf_root_dir').PATH_SEPARATOR.get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/../lib/vendor'.PATH_SEPARATOR.dirname(__FILE__).'/../lib/vendor/propel-generator/classes/'); 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelAutoload.php

    r7503 r7618  
    2020require_once('propel/Propel.php'); 
    2121 
    22 sfPropel::initialize(sfContext::hasInstance() ? sfContext::getInstance()->getEventDispatcher() : new sfEventDispatcher()); 
     22sfPropel::initialize(sfProjectConfiguration::getActive()->getEventDispatcher()); 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelData.class.php

    r7416 r7618  
    272272  protected function loadMapBuilders() 
    273273  { 
    274     $files = sfFinder::type('file')->name('*MapBuilder.php')->in(sfLoader::getModelDirs()); 
     274    $files = sfFinder::type('file')->name('*MapBuilder.php')->in(sfProjectConfiguration::getActive()->getModelDirs()); 
    275275    foreach ($files as $file) 
    276276    { 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelManyToMany.class.php

    r6707 r7618  
    5353 
    5454    // we must load all map builder classes 
    55     $classes = sfFinder::type('file')->name('*MapBuilder.php')->in(sfLoader::getModelDirs()); 
     55    $classes = sfFinder::type('file')->name('*MapBuilder.php')->in(sfProjectConfiguration::getActive()->getModelDirs()); 
    5656    foreach ($classes as $class) 
    5757    { 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelCrudGenerator.class.php

    r7223 r7618  
    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/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php

    r7507 r7618  
    428428  protected function loadBuilders() 
    429429  { 
    430     $classes = sfFinder::type('file')->name('*MapBuilder.php')->in(sfLoader::getModelDirs()); 
     430    $classes = sfFinder::type('file')->name('*MapBuilder.php')->in($this->generatorManager->getConfiguration()->getModelDirs()); 
    431431    foreach ($classes as $class) 
    432432    { 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBaseTask.class.php

    r7503 r7618  
    3333    if (!self::$done) 
    3434    { 
    35       $libDir = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'; 
     35      set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/../vendor'); 
     36 
     37      $libDir = dirname(__FILE__).'/..'; 
    3638 
    3739      $autoloader = sfSimpleAutoload::getInstance(); 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildFormsTask.class.php

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

    r7454 r7618  
    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/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataLoadTask.class.php

    r7454 r7618  
    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/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelGenerateCrudTask.class.php

    r7454 r7618  
    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'], 
     
    137137    // create basic application structure 
    138138    $finder = sfFinder::type('any')->ignore_version_control()->discard('.sf'); 
    139     $dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelCrud', $options['theme']); 
     139    $dirs = $this->configuration->getGeneratorSkeletonDirs('sfPropelCrud', $options['theme']); 
    140140    foreach ($dirs as $dir) 
    141141    { 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInitAdminTask.class.php

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

    r7196 r7618  
    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 
     
    7775 
    7876  // initialize database manager 
    79   $databaseManager = new sfDatabaseManager(); 
     77  $databaseManager = new sfDatabaseManager($configuration); 
    8078 
    8179  // cleanup database 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/backendTestBrowser.class.php

    r6487 r7618  
    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/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/symfony

    r7454 r7618  
    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/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/functional.php

    r5262 r7618  
    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/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/unit.php

    r5125 r7618  
    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/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/backend_dev.php

    r5125 r7618  
    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/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud.php

    r5125 r7618  
    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/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud_dev.php

    r5125 r7618  
    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/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/index.php

    r5125 r7618  
    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/dwhittle/1.1/lib/routing/sfPatternRouting.class.php

    r7527 r7618  
    7777  public function loadConfiguration() 
    7878  { 
    79     if ($config = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/routing.yml', true)) 
     79    if ($config = sfContext::getInstance()->getConfigCache()->checkConfig('config/routing.yml', true)) 
    8080    { 
    8181      require($config); 
     
    428428 
    429429      // all params must be given 
    430       if ($diff = array_diff_key($variables, array_filter($tparams))) 
     430      if ($diff = array_diff_key($variables, array_filter($tparams, create_function('$v', 'return !is_null($v);')))) 
    431431      { 
    432432        throw new InvalidArgumentException(sprintf('The "%s" route has some missing mandatory parameters (%s).', $name, implode(', ', $diff))); 
  • branches/dwhittle/1.1/lib/task/cache/sfCacheGenerateTask.class.php

    r7479 r7618  
    6969    $this->checkAppExists($application); 
    7070 
    71     // simulate a request to populate configuration cache files for the current application and environment 
    72     // only works for one application / environment per execution 
    73     define('SF_ROOT_DIR',    realpath('./')); 
    74     define('SF_APP',         $application); 
    75     define('SF_ENVIRONMENT', $environment); 
    76     define('SF_DEBUG',       true); 
    77  
    78     require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.sfConfig::get('sf_apps_dir_name', 'apps').DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.sfConfig::get('sf_config_dir_name', 'config').DIRECTORY_SEPARATOR.'config.php'); 
    79  
    80     // hide any warnings - like sessions for prod environment 
    81     $error_reporting = error_reporting(0); 
    82  
    83     // generate configuration + view cache 
     71    // simulate http requests to prime configuration/i18n/view cache 
    8472    $browser = new sfBrowser(); 
    8573    foreach($uris as $uri) 
     
    8977 
    9078    // generate core_compile 
    91     sfConfigCache::getInstance()->checkConfig('config/core_compile.yml'); 
    92  
    93     error_reporting($error_reporting); 
     79    $configuration = sfApplicationConfiguration::getForApplication($application, $environment, true, realpath('./')); 
     80    $configuration->getConfigCache()->checkConfig('config/core_compile.yml'); 
    9481 
    9582    $this->logSection('cache', sprintf('generated cache for application "%s" in environment "%s"', $application, $environment)); 
  • branches/dwhittle/1.1/lib/task/generator/sfGenerateAppTask.class.php

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

    r7416 r7618  
    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__).DIRECTORY_SEPARATOR.'skeleton'.DIRECTORY_SEPARATOR.'project', sfConfig::get('sf_root_dir'), $finder); 
    7272 
    7373    // Update project configuration files 
    74     $finder = sfFinder::type('file')->name('config.php', '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'), 
    77                                                                                                     'PROJECT_DOMAIN' => php_uname('n'), 
    78                                                                                                     'SYMFONY_LIB_DIR'  => sfConfig::get('sf_symfony_lib_dir'), 
    79                                                                                                     )); 
     74    $finder = sfFinder::type('file')->name('properties.ini', '*apache*.conf', 'propel.ini'); 
     75    $this->getFilesystem()->replaceTokens(array_merge(array(sfConfig::get('sf_lib_dir').'/ProjectConfiguration.class.php'), $finder->in(sfConfig::get('sf_config_dir'))), '##', '##', 
     76                                          array('PROJECT_NAME'   => $arguments['name'], 
     77                                                'PROJECT_DIR'    => sfConfig::get('sf_root_dir'), 
     78                                                'PROJECT_DOMAIN' => php_uname('n'), 
     79                                                'SYMFONY_LIB_DIR'  => sfConfig::get('sf_symfony_lib_dir'), 
     80                                                )); 
    8081 
    8182    $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); 
  • branches/dwhittle/1.1/lib/task/generator/skeleton/app/web/index.php

    r7462 r7618  
    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/dwhittle/1.1/lib/task/generator/skeleton/project/symfony

    r7349 r7618  
    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/dwhittle/1.1/lib/task/generator/skeleton/project/test/bootstrap/functional.php

    r7310 r7618  
    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/dwhittle/1.1/lib/task/generator/skeleton/project/test/bootstrap/unit.php

    r7310 r7618  
    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.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'lime'.DIRECTORY_SEPARATOR.'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/dwhittle/1.1/lib/task/i18n/sfI18nExtractTask.class.php

    r7454 r7618  
    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 
    9088    $extract->extract(); 
  • branches/dwhittle/1.1/lib/task/i18n/sfI18nFindTask.class.php

    r7416 r7618  
    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/dwhittle/1.1/lib/task/project/sfProjectClearControllersTask.class.php

    r7416 r7618  
    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/dwhittle/1.1/lib/task/project/sfProjectFreezeTask.class.php

    r7416 r7618  
    7575    } 
    7676 
    77     $symfony_lib_dir  = sfConfig::get('sf_symfony_lib_dir'); 
    78     $symfony_data_dir = $arguments['symfony_data_dir']; 
     77    $symfonyLibDir  = sfConfig::get('sf_symfony_lib_dir'); 
     78    $symfonyDataDir = $arguments['symfony_data_dir']; 
    7979 
    80     $this->logSection('freeze', sprintf('freezing lib found in "%s', $symfony_lib_dir)); 
    81     $this->logSection('freeze', sprintf('freezing data found in "%s"', $symfony_data_dir)); 
     80    $this->logSection('freeze', sprintf('freezing lib found in "%s', $symfonyLibDir)); 
     81    $this->logSection('freeze', sprintf('freezing data found in "%s"', $symfonyDataDir)); 
    8282 
    8383    $this->getFilesystem()->mkdirs($sf_lib_dir.DIRECTORY_SEPARATOR.'symfony'); 
    8484    $this->getFilesystem()->mkdirs($sf_data_dir.DIRECTORY_SEPARATOR.'symfony'); 
    8585 
    86     $finder = sfFinder::type('any')->ignore_version_control()
    87     $this->getFilesystem()->mirror($symfony_lib_dir, $sf_lib_dir.DIRECTORY_SEPARATOR.'symfony', $finder); 
    88     $this->getFilesystem()->mirror($symfony_data_dir, $sf_data_dir.DIRECTORY_SEPARATOR.'symfony', $finder); 
     86    $finder = sfFinder::type('any')->ignore_version_control()->exec(array($this, 'excludeTests'))
     87    $this->getFilesystem()->mirror($symfonyLibDir, sfConfig::get('sf_lib_dir').'/symfony', $finder); 
     88    $this->getFilesystem()->mirror($symfonyDataDir, sfConfig::get('sf_data_dir').'/symfony', $finder); 
    8989 
    9090    $this->getFilesystem()->rename($sf_data_dir.DIRECTORY_SEPARATOR.'symfony'.DIRECTORY_SEPARATOR.'web'.DIRECTORY_SEPARATOR.'sf', $sf_web_dir.DIRECTORY_SEPARATOR.'sf'); 
    9191 
    92     // change symfony paths in config/config.php 
    93     file_put_contents('config/config.php.bak', $symfony_lib_dir); 
    94     $this->changeSymfonyDirs("dirname(__FILE__).'/../lib/symfony'"); 
     92    // change symfony path in ProjectConfiguration.class.php 
     93    $config = sfConfig::get('sf_lib_dir').'/ProjectConfiguration.class.php'; 
     94    $content = file_get_contents($config); 
     95    $content = str_replace('<?php', "<?php\n\n# FROZEN_SF_LIB_DIR: $symfonyLibDir", $content); 
     96    $content = preg_replace('#(\'|")'.preg_quote($symfonyLibDir, '#').'#', "dirname(__FILE__).$1/../lib/symfony", $content); 
     97    file_put_contents($config, $content); 
    9598  } 
    9699 
    97   protected function changeSymfonyDirs($symfony_lib_dir
     100  public function excludeTests($dir, $entry
    98101  { 
    99     $sf_config_dir = sfConfig::get('sf_config_dir'); 
    100  
    101     $content = file_get_contents($sf_config_dir.DIRECTORY_SEPARATOR.'config.php'); 
    102     $content = preg_replace("/^(\s*.sf_symfony_lib_dir\s*=\s*).+?;/m", "$1$symfony_lib_dir;", $content); 
    103     file_put_contents($sf_config_dir.DIRECTORY_SEPARATOR.'config.php', $content); 
     102    return false === strpos($dir.'/'.$entry, 'Plugin/test/'); 
    104103  } 
    105104} 
  • branches/dwhittle/1.1/lib/task/project/sfProjectUnfreezeTask.class.php

    r7416 r7618  
    5656    } 
    5757 
    58     $this->changeSymfonyDirs("'".file_get_contents('config/config.php.bak')."'"); 
     58    // change symfony path in ProjectConfiguration.class.php 
     59    $config = sfConfig::get('sf_lib_dir').'/ProjectConfiguration.class.php'; 
     60    $content = file_get_contents($config); 
     61    if (preg_match('/^# FROZEN_SF_LIB_DIR\: (.+?)$/m', $content, $match)) 
     62    { 
     63      $content = str_replace("# FROZEN_SF_LIB_DIR: {$match[1]}\n\n", '', $content); 
     64      $content = preg_replace('#^require_once.+?$#m', "require_once '{$match[1]}/autoload/sfCoreAutoload.class.php';", $content, 1); 
     65      file_put_contents($config, $content); 
     66    } 
    5967 
    6068    $finder = sfFinder::type('any'); 
     
    6573    $this->getFilesystem()->remove($finder->in($sf_web_dir.DIRECTORY_SEPARATOR.'sf')); 
    6674    $this->getFilesystem()->remove($sf_web_dir.DIRECTORY_SEPARATOR.'sf'); 
    67    } 
    68  
    69   protected function changeSymfonyDirs($symfony_lib_dir) 
    70   { 
    71     $sf_config_dir = sfConfig::get('sf_config_dir'); 
    72  
    73     $content = file_get_contents($sf_config_dir.DIRECTORY_SEPARATOR.'config.php'); 
    74     $content = preg_replace("/^(\s*.sf_symfony_lib_dir\s*=\s*).+?;/m", "$1$symfony_lib_dir;", $content); 
    75     file_put_contents($sf_config_dir.DIRECTORY_SEPARATOR.'config.php', $content); 
    7675  } 
    7776} 
  • branches/dwhittle/1.1/lib/task/project/upgrade1.1/sfConfigUpgrade.class.php

    r7416 r7618  
    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/dwhittle/1.1/lib/task/project/upgrade1.1/sfUpgrade.class.php

    r7416 r7618  
    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/dwhittle/1.1/lib/task/sfBaseTask.class.php

    r7416 r7618  
    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 = 'cli', $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/dwhittle/1.1/lib/task/test/sfTestFunctionalTask.class.php

    r6932 r7618  
    6363      foreach ($arguments['controller'] as $controller) 
    6464      { 
    65         $files = sfFinder::type('file')->ignore_version_control()->follow_link()->name(basename($controller).'Test.php')->in(sfConfig::get('sf_test_functional_dir').DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.dirname($controller)); 
     65        $files = sfFinder::type('file')->ignore_version_control()->follow_link()->name(basename($controller).'Test.php')->in(sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'functional'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.dirname($controller)); 
    6666        foreach ($files as $file) 
    6767        { 
     
    7575 
    7676      $h = new lime_harness(new lime_output_color()); 
    77       $h->base_dir = sfConfig::get('sf_test_functional_dir').DIRECTORY_SEPARATOR.$app; 
     77      $h->base_dir = sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'functional'.DIRECTORY_SEPARATOR.$app; 
    7878 
    7979      // register functional tests 
  • branches/dwhittle/1.1/lib/task/test/sfTestUnitTask.class.php

    r6932 r7618  
    7070 
    7171      $h = new lime_harness(new lime_output_color()); 
    72       $h->base_dir = sfConfig::get('sf_test_unit_dir')
     72      $h->base_dir = sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'unit'
    7373 
    7474      // register unit tests 
  • branches/dwhittle/1.1/lib/util/sfBrowser.class.php

    r6846 r7618  
    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 
     
    232232 
    233233    // dispatch our request 
    234     ob_start(); 
    235234    $controller->dispatch(); 
     235 
    236236    $retval = ob_get_clean(); 
    237237 
     
    366366 
    367367  /** 
    368    * Gets context. 
     368   * Returns the current application context. 
     369   * 
     370   * @param  Boolean true to force context reload, false otherwise 
    369371   * 
    370372   * @return sfContext 
    371373   */ 
    372   public function getContext() 
    373   { 
     374  public function getContext($forceReload = false) 
     375  { 
     376    if (is_null($this->context) || $forceReload) 
     377    { 
     378      $this->context = sfContext::getInstance(); 
     379      $this->context->initialize($this->context->getConfiguration()); 
     380      $this->context->getEventDispatcher()->connect('application.throw_exception', array($this, 'ListenToException')); 
     381    } 
     382 
    374383    return $this->context; 
    375384  } 
  • branches/dwhittle/1.1/lib/util/sfContext.class.php

    r7574 r7618  
    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->asResponse()->send(); 
    57     } 
    58     catch (Exception $e) 
    59     { 
    60       sfException::createFromException($e)->asResponse()->send(); 
    61     } 
    62  
    63     $this->dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters')); 
    64  
    65     // register our shutdown function 
    66     register_shutdown_function(array($this, 'shutdown')); 
    67   } 
    68  
    69   /** 
    70    * Retrieves the singleton instance of this class. 
    71    * 
    72    * @param  string    The name of the sfContext to retrieve. 
    73    * 
    74    * @return sfContext A sfContext implementation instance. 
    75    */ 
    76   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__) 
    7744  { 
    7845    if (is_null($name)) 
    7946    { 
    80       $name = self::$current; 
    81     } 
     47      $name = $configuration->getApplication(); 
     48    } 
     49 
     50    self::$current = $name; 
    8251 
    8352    if (!isset(self::$instances[$name])) 
     
    9059      } 
    9160 
    92       self::$instances[$name]->initialize(); 
     61      self::$instances[$name]->initialize($configuration); 
    9362    } 
    9463 
     
    9766 
    9867  /** 
     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->asResponse()->send(); 
     84    } 
     85    catch (Exception $e) 
     86    { 
     87      sfException::createFromException($e)->asResponse()->send(); 
     88    } 
     89 
     90    $this->dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters')); 
     91 
     92    // register our shutdown function 
     93    register_shutdown_function(array($this, 'shutdown')); 
     94  } 
     95 
     96  /** 
     97   * Retrieves the singleton instance of this class. 
     98   * 
     99   * @param  string    The name of the sfContext to retrieve. 
     100   * 
     101   * @return sfContext A sfContext implementation instance. 
     102   */ 
     103  static public function getInstance($name = null, $class = __CLASS__) 
     104  { 
     105    if (is_null($name)) 
     106    { 
     107      $name = self::$current; 
     108    } 
     109 
     110    if (!isset(self::$instances[$name])) 
     111    { 
     112      throw new sfException(sprintf('The "%s" context does not exist.', $name)); 
     113    } 
     114 
     115    return self::$instances[$name]; 
     116  } 
     117 
     118  /** 
    99119   * Checks to see if there has been a context created 
    100120   * 
    101    * @param  string    The name of the sfContext to check for 
     121   * @param  string   The name of the sfContext to check for 
    102122   * 
    103123   * @return boolean  True is instanced, otherwise false 
     
    115135 
    116136  /** 
    117    * 
     137   * Loads the symfony factories. 
     138   */ 
     139  public function loadFactories() 
     140  { 
     141    if (sfConfig::get('sf_use_database')) 
     142    { 
     143      // setup our database connections 
     144      $this->factories['databaseManager'] = new sfDatabaseManager($this->configuration, array('auto_shutdown' => false)); 
     145    } 
     146 
     147    // create a new action stack 
     148    $this->factories['actionStack'] = new sfActionStack(); 
     149 
     150    // include the factories configuration 
     151    require($this->configuration->getConfigCache()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/factories.yml')); 
     152 
     153    $this->dispatcher->notify(new sfEvent($this, 'context.load_factories')); 
     154  } 
     155 
     156  /** 
     157   * Dispatches the current request. 
     158   */ 
     159  public function dispatch() 
     160  { 
     161    $this->getController()->dispatch(); 
     162  } 
     163 
     164  /** 
    118165   * Sets the current context to something else 
    119166   * 
     
    124171  { 
    125172    self::$current = $name; 
     173  } 
     174 
     175  /** 
     176   * Returns the configuration instance. 
     177   * 
     178   * @return sfConfiguration The sfConfiguration instance 
     179   */ 
     180  public function getConfiguration() 
     181  { 
     182    return $this->configuration; 
    126183  } 
    127184 
     
    341398 
    342399  /** 
     400   * Returns the configuration cache. 
     401   * 
     402   * @return sfConfigCache A sfConfigCache instance 
     403   */ 
     404  public function getConfigCache() 
     405  { 
     406    return $this->configuration->getConfigCache(); 
     407  } 
     408 
     409  /** 
    343410   * Gets an object from the current context. 
    344411   * 
  • branches/dwhittle/1.1/lib/view/sfPHPView.class.php

    r7416 r7618  
    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/dwhittle/1.1/lib/view/sfPartialView.class.php

    r7416 r7618  
    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/dwhittle/1.1/lib/view/sfViewCacheManager.class.php

    r6602 r7618  
    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/dwhittle/1.1/test/bin/loc.php

    r7377 r7618  
    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/dwhittle/1.1/test/bootstrap/functional.php

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

    r7454 r7618  
    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/dwhittle/1.1/test/functional/fixtures/project/test/bootstrap/functional.php

    r5262 r7618  
    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/dwhittle/1.1/test/functional/fixtures/project/test/bootstrap/unit.php

    r2594 r7618  
    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/dwhittle/1.1/test/functional/fixtures/project/web/cache.php

    r2369 r7618  
    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/dwhittle/1.1/test/functional/fixtures/project/web/cache_dev.php

    r2369 r7618  
    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/dwhittle/1.1/test/functional/fixtures/project/web/frontend_dev.php

    r2369 r7618  
    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/dwhittle/1.1/test/functional/fixtures/project/web/i18n.php

    r2823 r7618  
    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/dwhittle/1.1/test/functional/fixtures/project/web/i18n_dev.php

    r2823 r7618  
    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/dwhittle/1.1/test/functional/fixtures/project/web/index.php

    r2369 r7618  
    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/dwhittle/1.1/test/other/tasksTest.php

    r7503 r7618  
    122122 
    123123$content = $c->execute_command(sprintf('project:freeze %s', realpath(dirname(__FILE__).'/../../data'))); 
    124 $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'); 
     124$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'); 
    125125 
    126126$content = $c->execute_command('project:unfreeze'); 
    127 $t->unlike(file_get_contents($c->tmp_dir.DS.'config'.DS.'config.php'), '/dirname\(__FILE__\)/', '"project:unfreeze" unfreezes symfony lib and data dir'); 
     127$t->unlike(file_get_contents($c->tmp_dir.DS.'lib'.DS.'ProjectConfiguration.class.php'), '/dirname\(__FILE__\)/', '"project:unfreeze" unfreezes symfony lib and data dir'); 
    128128 
    129129$c->shutdown(); 
  • branches/dwhittle/1.1/test/unit/config/sfConfigCacheTest.php

    r4149 r7618  
    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/dwhittle/1.1/test/unit/generator/sfGeneratorTest.php

    r4963 r7618  
    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/dwhittle/1.1/test/unit/i18n/extract/sfI18nExtractTest.php

    r7524 r7618  
    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, array('cache' => $cache)); 
     29 
     30$i18n = new sfI18N($configuration, $cache); 
    2631 
    2732class sfI18nExtractTest extends sfI18nExtract 
  • branches/dwhittle/1.1/test/unit/i18n/sfI18NTest.php

    r7524 r7618  
    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, array('cache' => $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, array('cache' => $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, array('cache' => $cache, '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, array('cache' => $cache, '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, array('cache' => $cache, '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, array('cache' => $cache, '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, array('cache' => $cache, '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, array('cache' => $cache, '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, array('cache' => $cache, '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/dwhittle/1.1/test/unit/routing/sfPatternRoutingTest.php

    r7527 r7618  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(127, new lime_output_color()); 
     13 
     14$t = new lime_test(128, new lime_output_color()); 
    1415 
    1516class sfPatternRoutingTest extends sfPatternRouting 
     
    485486} 
    486487 
     488// parameters can be empty 
     489$t->diag('parameters can be empty'); 
     490$r->clearRoutes(); 
     491$r->connect('test', '/test/:foo/:bar'); 
     492$t->is($r->generate('test', array('foo' => 'bar', 'bar' => '')), '/test/bar/', '->generate() can take empty parameters'); 
     493 
     494// default module/action overriding 
     495$t->diag('module/action overriding'); 
     496$r->clearRoutes(); 
     497try 
     498{ 
     499  $r->generate('', $params); 
     500  $t->fail('->generate() throws a sfConfigurationException if no route matches the params'); 
     501} 
     502catch (sfConfigurationException $e) 
     503{ 
     504  $t->pass('->generate() throws a sfConfigurationException if no route matches the params'); 
     505} 
    487506 
    488507// no route matches 
     
    491510try 
    492511{ 
    493   $r->generate('', $params); 
    494   $t->fail('->generate() throws a sfConfigurationException if no route matches the params'); 
    495 } 
    496 catch (sfConfigurationException $e) 
    497 { 
    498   $t->pass('->generate() throws a sfConfigurationException if no route matches the params'); 
    499 } 
    500  
    501 $r->clearRoutes(); 
    502 try 
    503 { 
    504512  $r->parse('/test'); 
    505513  $t->fail('->parse() routes that do not match throw sfError404Exception'); 
  • branches/dwhittle/1.1/test/unit/sfContextMock.class.php

    r7578 r7618  
    99 */ 
    1010 
     11require_once(sfConfig::get('sf_symfony_lib_dir').'/config/sfProjectConfiguration.class.php'); 
     12class ProjectConfiguration extends sfProjectConfiguration 
     13{ 
     14 
     15} 
     16 
     17class ApplicationConfiguration extends ProjectConfiguration 
     18{ 
     19 
     20} 
     21 
    1122class sfContext 
    1223{ 
     
    1526 
    1627  public 
     28    $configuration = null, 
    1729    $request    = null, 
    1830    $response   = null, 
     
    2133    $user       = null, 
    2234    $storage    = null, 
    23     $i18n    = null; 
     35    $i18n       = null, 
     36    $cache      = null; 
    2437 
    2538  protected 
     
    3548      self::$instance->storage = new sfSessionTestStorage(array('session_path' => self::$instance->sessionPath)); 
    3649 
    37       self::$instance->dispatcher = new sfEventDispatcher(); 
     50      self::$instance->cache = new sfNoCache(); 
     51      self::$instance->configuration = new ApplicationConfiguration(); 
     52      self::$instance->dispatcher = self::$instance->configuration->getEventDispatcher(); 
    3853 
    3954      foreach ($factories as $type => $class) 
     
    106121  } 
    107122 
     123  public function getCache() 
     124  { 
     125    return $this->cache; 
     126  } 
     127 
     128  public function getConfiguration() 
     129  { 
     130    return $this->configuration; 
     131  } 
     132 
     133  public function getConfigCache() 
     134  { 
     135    return $this->configuration->getConfigCache(); 
     136  } 
     137 
    108138  public function inject($type, $class, $parameters = array()) 
    109139  { 
     
    121151        break; 
    122152      case 'i18n': 
    123         $object = new $class($this->dispatcher, $parameters); 
     153        $object = new $class($this->configuration, $this->cache, $parameters); 
    124154        break; 
    125155      default: 
  • branches/dwhittle/1.1/test/unit/task/cache/sfCacheClearTaskTest.php

    r6860 r7618  
    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/dwhittle/1.1/test/unit/util/sfContextTest.php

    r4494 r7618  
    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.
Sensio Labs also supports several large Open-Source projects.