Changeset 7618
- Timestamp:
- 02/27/08 01:02:41 (2 years ago)
- Files:
-
- branches/dwhittle/1.1/UPGRADE (modified) (3 diffs)
- branches/dwhittle/1.1/lib/action/sfAction.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/autoload/sfAutoload.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/autoload/sfCoreAutoload.class.php (modified) (6 diffs)
- branches/dwhittle/1.1/lib/command/cli.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/command/sfSymfonyCommandApplication.class.php (modified) (4 diffs)
- branches/dwhittle/1.1/lib/config/config/core_compile.yml (modified) (2 diffs)
- branches/dwhittle/1.1/lib/config/sfApplicationConfiguration.class.php (copied) (copied from branches/1.1/lib/config/sfApplicationConfiguration.class.php) (1 diff)
- branches/dwhittle/1.1/lib/config/sfCompileConfigHandler.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/config/sfConfigCache.class.php (modified) (4 diffs)
- branches/dwhittle/1.1/lib/config/sfConfigDimension.class.php (deleted)
- branches/dwhittle/1.1/lib/config/sfFactoryConfigHandler.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/config/sfGeneratorConfigHandler.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/config/sfLoader.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/config/sfProjectConfiguration.class.php (copied) (copied from branches/1.1/lib/config/sfProjectConfiguration.class.php)
- branches/dwhittle/1.1/lib/controller/default/templates/moduleSuccess.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/controller/sfController.class.php (modified) (3 diffs)
- branches/dwhittle/1.1/lib/database/sfDatabaseManager.class.php (modified) (4 diffs)
- branches/dwhittle/1.1/lib/filter/sfFilterChain.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/generator/sfCrudGenerator.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/generator/sfGenerator.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/generator/sfGeneratorManager.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/i18n/extract/sfI18nModuleExtract.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/i18n/sfI18N.class.php (modified) (6 diffs)
- branches/dwhittle/1.1/lib/log/sfWebDebugLogger.class.php (modified) (4 diffs)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/config/config.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/lib/filter/sfValidationExecutionFilter.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/lib/helper/PartialHelper.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/lib/view/sfMailView.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/bootstrap/functional.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/apps/frontend/config/config.php (deleted)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/config/config.php (deleted)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/lib/ProjectConfiguration.class.php (copied) (copied from branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/lib/ProjectConfiguration.class.php)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/lib/frontendConfiguration.class.php (copied) (copied from branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/lib/frontendConfiguration.class.php)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/symfony (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/functional.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/unit.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/frontend_dev.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/index.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/unit/validator/sfDateValidatorTest.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/config/config.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelAutoload.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelData.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelManyToMany.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelCrudGenerator.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBaseTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildFormsTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataDumpTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataLoadTask.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelGenerateCrudTask.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInitAdminTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/bootstrap/functional.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/backendTestBrowser.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/apps/backend/config/config.php (deleted)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/apps/crud/config/config.php (deleted)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/config/config.php (deleted)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/ProjectConfiguration.class.php (copied) (copied from branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/ProjectConfiguration.class.php)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/backendConfiguration.class.php (copied) (copied from branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/backendConfiguration.class.php)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/crudConfiguration.class.php (copied) (copied from branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/crudConfiguration.class.php)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/symfony (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/functional.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/unit.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/backend_dev.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud_dev.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/index.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/routing/sfPatternRouting.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/task/cache/sfCacheGenerateTask.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/task/generator/sfGenerateAppTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/generator/sfGenerateProjectTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/generator/skeleton/app/app/config/config.php (deleted)
- branches/dwhittle/1.1/lib/task/generator/skeleton/app/lib (copied) (copied from branches/1.1/lib/task/generator/skeleton/app/lib)
- branches/dwhittle/1.1/lib/task/generator/skeleton/app/lib/ApplicationConfiguration.class.php (copied) (copied from branches/1.1/lib/task/generator/skeleton/app/lib/ApplicationConfiguration.class.php)
- branches/dwhittle/1.1/lib/task/generator/skeleton/app/web/index.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/generator/skeleton/project/config/config.php (deleted)
- branches/dwhittle/1.1/lib/task/generator/skeleton/project/lib/ProjectConfiguration.class.php (copied) (copied from branches/1.1/lib/task/generator/skeleton/project/lib/ProjectConfiguration.class.php)
- branches/dwhittle/1.1/lib/task/generator/skeleton/project/symfony (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/generator/skeleton/project/test/bootstrap/functional.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/generator/skeleton/project/test/bootstrap/unit.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/i18n/sfI18nExtractTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/i18n/sfI18nFindTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/project/sfProjectClearControllersTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/project/sfProjectFreezeTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/project/sfProjectUnfreezeTask.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/task/project/upgrade1.1/sfAutoloadingUpgrade.class.php (deleted)
- branches/dwhittle/1.1/lib/task/project/upgrade1.1/sfConfigUpgrade.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/project/upgrade1.1/sfTestUpgrade.class.php (copied) (copied from branches/1.1/lib/task/project/upgrade1.1/sfTestUpgrade.class.php)
- branches/dwhittle/1.1/lib/task/project/upgrade1.1/sfUpgrade.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/task/sfBaseTask.class.php (modified) (3 diffs)
- branches/dwhittle/1.1/lib/task/test/sfTestFunctionalTask.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/task/test/sfTestUnitTask.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/util/CartesianIterator.class.php (deleted)
- branches/dwhittle/1.1/lib/util/sfBrowser.class.php (modified) (3 diffs)
- branches/dwhittle/1.1/lib/util/sfContext.class.php (modified) (7 diffs)
- branches/dwhittle/1.1/lib/util/sfCore.class.php (deleted)
- branches/dwhittle/1.1/lib/view/sfPHPView.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/view/sfPartialView.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/view/sfViewCacheManager.class.php (modified) (1 diff)
- branches/dwhittle/1.1/test/bin/loc.php (modified) (1 diff)
- branches/dwhittle/1.1/test/bootstrap/functional.php (modified) (1 diff)
- branches/dwhittle/1.1/test/functional/configTest.php (deleted)
- branches/dwhittle/1.1/test/functional/dimensionsTest.php (deleted)
- branches/dwhittle/1.1/test/functional/fixtures/project/apps/cache/config/config.php (deleted)
- branches/dwhittle/1.1/test/functional/fixtures/project/apps/dimensions (deleted)
- branches/dwhittle/1.1/test/functional/fixtures/project/apps/frontend/config/config.php (deleted)
- branches/dwhittle/1.1/test/functional/fixtures/project/apps/i18n/config/config.php (deleted)
- branches/dwhittle/1.1/test/functional/fixtures/project/apps/routing/config/config.php (deleted)
- branches/dwhittle/1.1/test/functional/fixtures/project/config/config.php (deleted)
- branches/dwhittle/1.1/test/functional/fixtures/project/config/dimensions.yml (deleted)
- branches/dwhittle/1.1/test/functional/fixtures/project/lib/ProjectConfiguration.class.php (copied) (copied from branches/1.1/test/functional/fixtures/project/lib/ProjectConfiguration.class.php)
- branches/dwhittle/1.1/test/functional/fixtures/project/lib/cacheConfiguration.class.php (copied) (copied from branches/1.1/test/functional/fixtures/project/lib/cacheConfiguration.class.php)
- branches/dwhittle/1.1/test/functional/fixtures/project/lib/frontendConfiguration.class.php (copied) (copied from branches/1.1/test/functional/fixtures/project/lib/frontendConfiguration.class.php)
- branches/dwhittle/1.1/test/functional/fixtures/project/lib/i18nConfiguration.class.php (copied) (copied from branches/1.1/test/functional/fixtures/project/lib/i18nConfiguration.class.php)
- branches/dwhittle/1.1/test/functional/fixtures/project/lib/routingConfiguration.class.php (added)
- branches/dwhittle/1.1/test/functional/fixtures/project/symfony (modified) (1 diff)
- branches/dwhittle/1.1/test/functional/fixtures/project/test/bootstrap/functional.php (modified) (2 diffs)
- branches/dwhittle/1.1/test/functional/fixtures/project/test/bootstrap/unit.php (modified) (1 diff)
- branches/dwhittle/1.1/test/functional/fixtures/project/web/cache.php (modified) (1 diff)
- branches/dwhittle/1.1/test/functional/fixtures/project/web/cache_dev.php (modified) (1 diff)
- branches/dwhittle/1.1/test/functional/fixtures/project/web/frontend_dev.php (modified) (1 diff)
- branches/dwhittle/1.1/test/functional/fixtures/project/web/i18n.php (modified) (1 diff)
- branches/dwhittle/1.1/test/functional/fixtures/project/web/i18n_dev.php (modified) (1 diff)
- branches/dwhittle/1.1/test/functional/fixtures/project/web/index.php (modified) (1 diff)
- branches/dwhittle/1.1/test/other/tasksTest.php (modified) (1 diff)
- branches/dwhittle/1.1/test/unit/config/sfConfigCacheTest.php (modified) (1 diff)
- branches/dwhittle/1.1/test/unit/config/sfConfigDimensionTest.php (deleted)
- branches/dwhittle/1.1/test/unit/generator/sfGeneratorTest.php (modified) (1 diff)
- branches/dwhittle/1.1/test/unit/i18n/extract/sfI18nExtractTest.php (modified) (2 diffs)
- branches/dwhittle/1.1/test/unit/i18n/sfI18NTest.php (modified) (7 diffs)
- branches/dwhittle/1.1/test/unit/routing/sfPatternRoutingTest.php (modified) (3 diffs)
- branches/dwhittle/1.1/test/unit/sfContextMock.class.php (modified) (6 diffs)
- branches/dwhittle/1.1/test/unit/task/cache/sfCacheClearTaskTest.php (modified) (2 diffs)
- branches/dwhittle/1.1/test/unit/util/sfContextTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dwhittle/1.1/UPGRADE
r7522 r7618 13 13 To upgrade a project: 14 14 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. 17 19 18 20 * 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'); 21 26 include($sf_symfony_data_dir.'/bin/symfony.php'); 22 27 23 28 to 24 29 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 26 62 27 63 * Launch the `project:upgrade1.1` task from your project directory … … 236 272 237 273 The `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 } 274 You can register autoloading callables in your application configuration class. 257 275 258 276 Thanks to the new `sfAutoload::autoloadAgain()` method, you won't need to clear 259 277 the cache when you add or move classes in your project. This method will 260 278 automatically find the changes and flush the autoloading cache. 261 262 The `project:upgrade1.1` task makes all those changes for you.263 279 264 280 … … 504 520 `data/exception.*` | `lib/exception/data` 505 521 506 The symfony core have been upgraded to take these changes into account. 522 The symfony core has been upgraded to take these changes into account. 523 524 sfLoader 525 -------- 526 527 All `sfLoader` static methods (except `::getHelperDirs()` and `::loadHelpers()`) 528 have been moved to the `sfProjectConfiguration` and `sfApplicationConfiguration` 529 classes: 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 546 sfCore 547 ------ 548 549 The `sfCore` has been removed. The code has been moved to `sfProjectConfiguration`, 550 `sfApplicationConfiguration`, and `sfContext` classes. 551 552 Front Controllers 553 ----------------- 554 555 All front controllers have to be upgraded. The SF_DEBUG, SF_APP, SF_ENVIRONMENT, 556 and SF_ROOT_DIR constants are gone. If you use some of these constants in your 557 project, 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 566 The `project:upgrade1.1` task upgrades all front controllers for you. 567 If you made some customizations, symfony will issue a warning and won't 568 upgrade them automatically. You can then copy the default skeleton from 569 symfony: /path/to/symfony/lib/task/generator/skeleton/app/web/index.php 570 571 config.php 572 ---------- 573 574 All `config.php` files have been removed. The are replaced by the `ProjectConfiguration` 575 class and the application configuration classes. 576 577 If you've added some cutomizations in `config.php` files, you will have to migrate them 578 to those new classes. branches/dwhittle/1.1/lib/action/sfAction.class.php
r6669 r7618 36 36 37 37 // 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)) 39 39 { 40 40 require($file); branches/dwhittle/1.1/lib/autoload/sfAutoload.class.php
r7255 r7618 87 87 public function reloadClasses($force = false) 88 88 { 89 if ($force) 89 $configuration = sfProjectConfiguration::getActive(); 90 if (!$configuration || !$configuration instanceof sfApplicationConfiguration) 90 91 { 91 @unlink(sfConfigCache::getInstance()->getCacheName(sfConfig::get('sf_app_config_dir_name').'/autoload.yml'));92 return; 92 93 } 93 94 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'); 95 101 96 102 $this->classes = include($file); … … 125 131 } 126 132 127 function autoloadAgain($class)133 public function autoloadAgain($class) 128 134 { 129 135 self::reloadClasses(true); branches/dwhittle/1.1/lib/autoload/sfCoreAutoload.class.php
r7454 r7618 158 158 'sfFormatter' => 'command', 159 159 'sfSymfonyCommandApplication' => 'command', 160 'sfApplicationConfiguration' => 'config', 160 161 'sfAutoloadConfigHandler' => 'config', 161 162 'sfCacheConfigHandler' => 'config', … … 163 164 'sfConfig' => 'config', 164 165 'sfConfigCache' => 'config', 165 'sfConfigDimension' => 'config',166 166 'sfConfigHandler' => 'config', 167 167 'sfDatabaseConfigHandler' => 'config', … … 171 171 'sfGeneratorConfigHandler' => 'config', 172 172 'sfLoader' => 'config', 173 'sfProjectConfiguration' => 'config', 173 174 'sfRootConfigHandler' => 'config', 174 175 'sfRoutingConfigHandler' => 'config', … … 322 323 'sfProjectUnfreezeTask' => 'task/project', 323 324 'sfUpgradeTo11Task' => 'task/project', 324 'sfAutoloadingUpgrade' => 'task/project/upgrade1.1',325 325 'sfComponentUpgrade' => 'task/project/upgrade1.1', 326 326 'sfConfigFileUpgrade' => 'task/project/upgrade1.1', … … 333 333 'sfRenderingFilterUpgrade' => 'task/project/upgrade1.1', 334 334 'sfSingletonUpgrade' => 'task/project/upgrade1.1', 335 'sfTestUpgrade' => 'task/project/upgrade1.1', 335 336 'sfUpgrade' => 'task/project/upgrade1.1', 336 337 'sfWebDebugUpgrade' => 'task/project/upgrade1.1', … … 346 347 'sfSecurityUser' => 'user', 347 348 'sfUser' => 'user', 348 'CartesianIterator' => 'util',349 349 'sfBrowser' => 'util', 350 350 'sfCallable' => 'util', 351 351 'sfContext' => 'util', 352 'sfCore' => 'util',353 352 'sfDomCssSelector' => 'util', 354 353 'sfFinder' => 'util', branches/dwhittle/1.1/lib/command/cli.php
r7349 r7618 16 16 $dispatcher = new sfEventDispatcher(); 17 17 $logger = new sfCommandLogger($dispatcher); 18 $options = array('symfony_lib_dir' => realpath(dirname(__FILE__).'/..'));19 18 20 $application = new sfSymfonyCommandApplication($dispatcher, new sfAnsiColorFormatter(), $options);19 $application = new sfSymfonyCommandApplication($dispatcher, new sfAnsiColorFormatter(), array('symfony_lib_dir' => realpath(dirname(__FILE__).'/..'))); 21 20 $application->run(); 22 21 } branches/dwhittle/1.1/lib/command/sfSymfonyCommandApplication.class.php
r7469 r7618 31 31 } 32 32 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()); 36 34 37 35 // application … … 39 37 $this->setVersion(SYMFONY_VERSION); 40 38 41 $this->initializeEnvironment($this->options['symfony_lib_dir']);42 39 $this->initializeTasks(); 43 40 } … … 74 71 75 72 /** 76 * Initializes the environment variables and include path.77 *78 * @param string The symfony lib directory79 */80 protected function initializeEnvironment($symfonyLibDir)81 {82 sfConfig::set('sf_symfony_lib_dir', $symfonyLibDir);83 84 // directory layout85 sfCore::initDirectoryLayout(getcwd());86 87 // include path88 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 /**97 73 * Loads all available tasks. 98 74 * … … 102 78 { 103 79 $dirs = array( 104 sfConfig::get('sf_symfony_lib_dir').'/task', // symfony tasks105 sfConfig::get('sf_symfony_lib_dir').'/plugins/*/lib/task', // bundled plugin tasks106 sfConfig::get('sf_plugins_dir').'/*/lib/task', // plugin tasks107 sfConfig::get('sf_lib_dir').'/task', // project tasks80 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 108 84 ); 109 85 $finder = sfFinder::type('file')->name('*Task.class.php'); 86 110 87 foreach ($dirs as $globDir) 111 88 { 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 7 2 8 3 # symfony core classes … … 17 12 - %SF_SYMFONY_LIB_DIR%/database/sfDatabase.class.php 18 13 - %SF_SYMFONY_LIB_DIR%/database/sfDatabaseManager.class.php 19 - %SF_SYMFONY_LIB_DIR%/event/sfEvent.class.php20 - %SF_SYMFONY_LIB_DIR%/event/sfEventDispatcher.class.php21 14 - %SF_SYMFONY_LIB_DIR%/filter/sfFilter.class.php 22 15 - %SF_SYMFONY_LIB_DIR%/filter/sfFilterChain.class.php branches/dwhittle/1.1/lib/config/sfApplicationConfiguration.class.php
r7614 r7618 186 186 { 187 187 // 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'))) 189 189 { 190 190 // clear cache branches/dwhittle/1.1/lib/config/sfCompileConfigHandler.class.php
r7377 r7618 65 65 66 66 // insert configuration files 67 $contents = preg_replace_callback(array('#(require|include)(_once)?\((sfConfigCache::getInstance\(\)|\$configCache)->checkConfig\([^_]+sf_app_config_dir_name[^\.]*\.\'/([^\']+)\'\)\);#m',68 '#()()(sfCon figCache::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'), 69 69 array($this, 'insertConfigFileCallback'), $contents); 70 70 */ 71 71 // strip php tags 72 72 $contents = sfToolkit::pregtr($contents, array('/^\s*<\?(php)?/m' => '', … … 103 103 $configFile = sfConfig::get('sf_app_config_dir_name').'/'.$matches[4]; 104 104 105 sfConfigCache::getInstance()->checkConfig($configFile); 105 $configCache = sfContext::getInstance()->getConfigCache(); 106 $configCache->checkConfig($configFile); 106 107 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)); 109 109 110 110 return $config; branches/dwhittle/1.1/lib/config/sfConfigCache.class.php
r7454 r7618 24 24 { 25 25 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; 45 38 } 46 39 … … 140 133 * 141 134 * If the configuration file path is relative, symfony will look in directories 142 * defined in the sf Loader::getConfigPaths() method.135 * defined in the sfConfiguration::getConfigPaths() method. 143 136 * 144 137 * @param string A filesystem path to a configuration file … … 148 141 * @throws <b>sfConfigurationException</b> If a requested configuration file does not exist 149 142 * 150 * @see sf Loader::getConfigPaths()143 * @see sfConfiguration::getConfigPaths() 151 144 */ 152 145 public function checkConfig($configPath, $optional = false) … … 167 160 if (!sfToolkit::isPathAbsolute($configPath)) 168 161 { 169 $files = sfLoader::getConfigPaths($configPath);162 $files = $this->configuration->getConfigPaths($configPath); 170 163 } 171 164 else branches/dwhittle/1.1/lib/config/sfFactoryConfigHandler.class.php
r7524 r7618 148 148 if (isset($parameters['cache'])) 149 149 { 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)); 151 151 unset($parameters['cache']); 152 152 } 153 153 else 154 154 { 155 $ instances[]= " \$cache = \$this->factories['cache'];\n";155 $cache = " \$cache = \$this->factories['cache'];\n"; 156 156 } 157 157 158 158 $instances[] = sprintf("\n if (sfConfig::get('sf_i18n'))\n {\n". 159 159 " \$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". 161 162 " }\n" 162 , $class, var_export($parameters, true)163 , $class, $cache, var_export($parameters, true) 163 164 ); 164 165 break; branches/dwhittle/1.1/lib/config/sfGeneratorConfigHandler.class.php
r6471 r7618 60 60 61 61 // generate class and add a reference to it 62 $generatorManager = new sfGeneratorManager( );62 $generatorManager = new sfGeneratorManager(sfContext::getInstance()->getConfiguration()); 63 63 64 64 // generator parameters branches/dwhittle/1.1/lib/config/sfLoader.class.php
r7314 r7618 19 19 class sfLoader 20 20 { 21 /**22 * Gets directories where model classes are stored.23 *24 * @return array An array of directories25 */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'); // project29 if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'model'))30 {31 $dirs = array_merge($dirs, $pluginDirs); // plugins32 }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 name41 *42 * @return array An array of directories43 */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; // application56 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 modules60 }61 62 $dirs[sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'controller'.DIRECTORY_SEPARATOR.$suffix] = true; // core modules63 64 return $dirs;65 }66 67 /**68 * Gets directories where template files are stored for a given module.69 *70 * @param string The module name71 *72 * @return array An array of directories73 */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; // application88 89 if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.$suffix))90 {91 $dirs = array_merge($dirs, $pluginDirs); // plugins92 }93 94 95 $dirs[] = sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'controller'.DIRECTORY_SEPARATOR.$suffix; // core modules96 $dirs[] = sfConfig::get('sf_module_cache_dir').DIRECTORY_SEPARATOR.'auto'.ucfirst($suffix); // generated templates in cache97 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 name105 * @param string The template file106 *107 * @return string A template directory108 */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 name127 * @param string The template file128 *129 * @return string A template path130 */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 directories142 */143 static public function getI18NGlobalDirs()144 {145 $dirs = array();146 147 // application148 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 // plugins154 $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 name167 *168 * @return array An array of i18n directories169 */170 static public function getI18NDirs($moduleName)171 {172 $dirs = array();173 174 // module175 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 // application181 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 plugins187 $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 // plugins194 $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 name207 * @param string The theme name208 *209 * @return array An array of directories210 */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; // project223 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); // plugin227 }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 plugin232 }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 name241 * @param string The theme name242 *243 * @return array An array of directories244 */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; // project257 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); // plugin261 }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 plugin266 }267 268 return $dirs;269 }270 271 /**272 * Gets the template to use for a generator class.273 *274 * @param string The generator class name275 * @param string The theme name276 * @param string The template path277 *278 * @return string A template path279 *280 * @throws sfException281 */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 path300 *301 * @return array An array of paths302 */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, // symfony315 );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 plugins320 }321 322 if ($pluginDirs = glob($sf_plugins_dir.DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.$globalConfigPath))323 {324 $files = array_merge($files, $pluginDirs); // plugins325 }326 327 if ($pluginDirs = glob($sf_plugins_dir.DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.$configPath))328 {329 $files = array_merge($files, $pluginDirs); // plugins330 }331 332 $files = array_merge($files, array(333 $sf_root_dir.DIRECTORY_SEPARATOR.$globalConfigPath, // project334 $sf_root_dir.DIRECTORY_SEPARATOR.$configPath, // project335 $sf_app_dir.DIRECTORY_SEPARATOR.$globalConfigPath, // application336 sfConfig::get('sf_app_cache_dir').DIRECTORY_SEPARATOR.$configPath, // generated modules337 ));338 339 $files[] = $sf_app_dir.DIRECTORY_SEPARATOR.$configPath; // module340 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 359 21 /** 360 22 * Gets the helper directories for a given module name. … … 448 110 } 449 111 } 450 451 /**452 * Loads config.php files from plugins453 *454 * @return void455 */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 }474 112 } branches/dwhittle/1.1/lib/controller/default/templates/moduleSuccess.php
r7349 r7618 15 15 <dd> 16 16 <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> 18 18 <li class="sfTEditMessage">In <code>actions/actions.class.php</code>, edit the <code>executeIndex()</code> method and remove the final <code>forward</code></li> 19 19 <li class="sfTColorMessage">Customize the <code>templates/indexSuccess.php</code> template</li> branches/dwhittle/1.1/lib/controller/sfController.class.php
r7513 r7618 99 99 protected function controllerExists($moduleName, $controllerName, $extension, $throwExceptions) 100 100 { 101 $dirs = sfLoader::getControllerDirs($moduleName);101 $dirs = $this->context->getConfiguration()->getControllerDirs($moduleName); 102 102 foreach ($dirs as $dir => $checkEnabled) 103 103 { … … 195 195 196 196 // 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); 198 198 199 199 if (!$this->actionExists($moduleName, $actionName)) … … 215 215 216 216 // 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')); 218 218 219 219 // check if this module is internal branches/dwhittle/1.1/lib/database/sfDatabaseManager.class.php
r7454 r7618 24 24 { 25 25 protected 26 $databases = array(); 26 $configuration = null, 27 $databases = array(); 27 28 28 29 /** … … 31 32 * @see initialize() 32 33 */ 33 public function __construct( $options = array())34 public function __construct(sfApplicationConfiguration $configuration, $options = array()) 34 35 { 35 $this->initialize( );36 $this->initialize($configuration); 36 37 37 38 if (isset($options['auto_shutdown']) && $options['auto_shutdown']) … … 44 45 * Initializes this sfDatabaseManager object 45 46 * 47 * @param sfApplicationConfiguration A sfApplicationConfiguration instance 48 * 46 49 * @return bool true, if initialization completes successfully, otherwise false 47 50 * 48 51 * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfDatabaseManager object 49 52 */ 50 public function initialize( )53 public function initialize(sfApplicationConfiguration $configuration) 51 54 { 55 $this->configuration = $configuration; 56 52 57 $this->loadConfiguration(); 53 58 } … … 58 63 public function loadConfiguration() 59 64 { 60 require( sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/databases.yml'));65 require($this->configuration->getConfigCache()->checkConfig('config/databases.yml')); 61 66 } 62 67 branches/dwhittle/1.1/lib/filter/sfFilterChain.class.php
r6506 r7618 32 32 public function loadConfiguration($actionInstance) 33 33 { 34 require(sfCon figCache::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')); 35 35 } 36 36 branches/dwhittle/1.1/lib/generator/sfCrudGenerator.class.php
r7490 r7618 72 72 // theme exists? 73 73 $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, ''); 75 75 if (!is_dir($themeDir)) 76 76 { branches/dwhittle/1.1/lib/generator/sfGenerator.class.php
r6159 r7618 78 78 protected function evalTemplate($templateFile) 79 79 { 80 $templateFile = sfLoader::getGeneratorTemplate($this->getGeneratorClass(), $this->getTheme(), $templateFile);80 $templateFile = $this->generatorManager->getConfiguration()->getGeneratorTemplate($this->getGeneratorClass(), $this->getTheme(), $templateFile); 81 81 82 82 // eval template file branches/dwhittle/1.1/lib/generator/sfGeneratorManager.class.php
r4963 r7618 19 19 class sfGeneratorManager 20 20 { 21 protected 22 $configuration = null; 23 21 24 /** 22 25 * Class constructor. 23 26 * 27 * @param sfProjectConfiguration A sfProjectConfiguration instance 28 * 24 29 * @see initialize() 25 30 */ 26 public function __construct( )31 public function __construct(sfProjectConfiguration $configuration) 27 32 { 28 $this->initialize( );33 $this->initialize($configuration); 29 34 } 30 35 31 36 /** 32 37 * Initializes the sfGeneratorManager instance. 38 * 39 * @param sfProjectConfiguration A sfProjectConfiguration instance 33 40 */ 34 public function initialize( )41 public function initialize(sfProjectConfiguration $configuration) 35 42 { 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; 36 54 } 37 55 branches/dwhittle/1.1/lib/i18n/extract/sfI18nModuleExtract.class.php
r4397 r7618 31 31 $this->module = $this->parameters['module']; 32 32 33 $this->i18n->setMessageSource( sfLoader::getI18NDirs($this->module), $this->culture);33 $this->i18n->setMessageSource($this->i18n->getConfiguration()->getI18NDirs($this->module), $this->culture); 34 34 } 35 35 branches/dwhittle/1.1/lib/i18n/sfI18N.class.php
r7524 r7618 20 20 { 21 21 protected 22 $configuration = null, 22 23 $dispatcher = null, 23 24 $cache = null, … … 32 33 * @see initialize() 33 34 */ 34 public function __construct(sf EventDispatcher $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); 37 38 } 38 39 … … 40 41 * Initializes this class. 41 42 * 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; 54 52 55 53 if (isset($options['culture'])) … … 67 65 ), $options); 68 66 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; 71 79 } 72 80 … … 155 163 if (!isset($this->messageSource)) 156 164 { 157 $this->setMessageSource( sfLoader::getI18NGlobalDirs(), $this->culture);165 $this->setMessageSource($this->configuration->getI18NGlobalDirs(), $this->culture); 158 166 } 159 167 … … 321 329 { 322 330 // change message source directory to our module 323 $this->setMessageSource( sfLoader::getI18NDirs($event['module']));331 $this->setMessageSource($this->configuration->getI18NDirs($event['module'])); 324 332 } 325 333 } branches/dwhittle/1.1/lib/log/sfWebDebugLogger.class.php
r6734 r7618 50 50 { 51 51 $this->xdebugLogging = $options['xdebug_logging']; 52 ini_set('memory_limit', '256M'); // xdebug can consume a lot of memory 52 53 } 53 54 … … 95 96 } 96 97 97 // add needed assets for the web debug toolbar98 // add web debug information to response content 98 99 $root = $this->context->getRequest()->getRelativeUrlRoot(); 99 100 $assets = sprintf(' … … 103 104 $root.sfConfig::get('sf_web_debug_web_dir').'/css/main.css' 104 105 ); 105 $content = str_ireplace('</head>', $assets.'</head>', $content);106 106 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)); 115 108 116 109 return $content; … … 132 125 { 133 126 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'))) 135 128 || !isset($stack['function']) 136 129 ) branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/config/config.php
r6745 r7618 13 13 14 14 // register config handler for validate/*.yml files 15 sf ConfigCache::getInstance()->registerConfigHandler('modules/*/validate/*.yml', 'sfValidatorConfigHandler');15 sfProjectConfiguration::getActive()->getConfigCache()->registerConfigHandler('modules/*/validate/*.yml', 'sfValidatorConfigHandler'); 16 16 17 17 // register the validation execution filter branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/lib/filter/sfValidationExecutionFilter.class.php
r6454 r7618 116 116 // load validation configuration 117 117 // 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)) 119 119 { 120 120 // create validator manager branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/lib/helper/PartialHelper.php
r6669 r7618 138 138 139 139 // load component's module config file 140 require(sfCon figCache::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')); 141 141 142 142 $componentInstance->getVarHolder()->add($vars); branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/lib/view/sfMailView.class.php
r5125 r7618 40 40 // require our configuration 41 41 $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')); 43 43 } 44 44 branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/bootstrap/functional.php
r5386 r7618 13 13 $root_dir = realpath(dirname(__FILE__).sprintf('/../%s/fixtures', isset($type) ? $type : 'functional')); 14 14 } 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);19 15 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'; 17 require $root_dir.'/lib/'.$class.'.class.php'; 18 $configuration = new $class('test', isset($debug) ? $debug : true); 19 sfContext::createInstance($configuration); 22 20 23 21 // remove all cache branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/symfony
r7454 r7618 11 11 12 12 chdir(dirname(__FILE__)); 13 include('config/config.php'); 14 include($sf_symfony_lib_dir.'/command/cli.php'); 13 require_once(dirname(__FILE__).'/lib/ProjectConfiguration.class.php'); 14 $configuration = new ProjectConfiguration(); 15 include($configuration->getSymfonyLibDir().'/command/cli.php'); branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/functional.php
r5321 r7618 4 4 * This file is part of the symfony package. 5 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 6 * 7 7 * For the full copyright and license information, please view the LICENSE 8 8 * file that was distributed with this source code. … … 14 14 $traces = debug_backtrace(); 15 15 $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); 17 19 } 18 20 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'; 22 require_once(dirname(__FILE__).'/../../lib/'.$class.'.class.php'); 24 23 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); 25 sfContext::createInstance($configuration); 27 26 28 27 // remove all cache branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/unit.php
r5321 r7618 10 10 11 11 $_test_dir = realpath(dirname(__FILE__).'/..'); 12 define('SF_ROOT_DIR', realpath($_test_dir.'/..'));13 12 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'); 13 require_once(dirname(__FILE__).'/../../lib/ProjectConfiguration.class.php'); 14 $configuration = new ProjectConfiguration(realpath($_test_dir.'/..')); 15 include($configuration->getSymfonyLibDir().'/vendor/lime/lime.php'); branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/frontend_dev.php
r5321 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'frontend'); 5 define('SF_ENVIRONMENT', 'dev'); 6 define('SF_DEBUG', true); 3 require_once(dirname(__FILE__).'/../lib/frontendConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/index.php
r5321 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'frontend'); 5 define('SF_ENVIRONMENT', 'prod'); 6 define('SF_DEBUG', false); 3 require_once(dirname(__FILE__).'/../lib/frontendConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/unit/validator/sfDateValidatorTest.php
r7578 r7618 19 19 20 20 $v = new sfDateValidator($context); 21 $v->initialize($context);22 21 23 22 // ->execute() branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/config/config.php
r5174 r7618 1 1 <?php 2 2 3 set_include_path( get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/../lib/vendor'.PATH_SEPARATOR.dirname(__FILE__).'/../lib/vendor/propel-generator/classes/');3 set_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 20 20 require_once('propel/Propel.php'); 21 21 22 sfPropel::initialize(sf Context::hasInstance() ? sfContext::getInstance()->getEventDispatcher() : new sfEventDispatcher());22 sfPropel::initialize(sfProjectConfiguration::getActive()->getEventDispatcher()); branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelData.class.php
r7416 r7618 272 272 protected function loadMapBuilders() 273 273 { 274 $files = sfFinder::type('file')->name('*MapBuilder.php')->in(sf Loader::getModelDirs());274 $files = sfFinder::type('file')->name('*MapBuilder.php')->in(sfProjectConfiguration::getActive()->getModelDirs()); 275 275 foreach ($files as $file) 276 276 { branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelManyToMany.class.php
r6707 r7618 53 53 54 54 // we must load all map builder classes 55 $classes = sfFinder::type('file')->name('*MapBuilder.php')->in(sf Loader::getModelDirs());55 $classes = sfFinder::type('file')->name('*MapBuilder.php')->in(sfProjectConfiguration::getActive()->getModelDirs()); 56 56 foreach ($classes as $class) 57 57 { branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelCrudGenerator.class.php
r7223 r7618 67 67 { 68 68 // 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()); 70 70 foreach ($classes as $class) 71 71 { branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php
r7507 r7618 428 428 protected function loadBuilders() 429 429 { 430 $classes = sfFinder::type('file')->name('*MapBuilder.php')->in( sfLoader::getModelDirs());430 $classes = sfFinder::type('file')->name('*MapBuilder.php')->in($this->generatorManager->getConfiguration()->getModelDirs()); 431 431 foreach ($classes as $class) 432 432 { branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBaseTask.class.php
r7503 r7618 33 33 if (!self::$done) 34 34 { 35 $libDir = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'; 35 set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/../vendor'); 36 37 $libDir = dirname(__FILE__).'/..'; 36 38 37 39 $autoloader = sfSimpleAutoload::getInstance(); branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildFormsTask.class.php
r7454 r7618 61 61 $this->logSection('propel', 'generating form classes'); 62 62 63 $generatorManager = new sfGeneratorManager( );63 $generatorManager = new sfGeneratorManager($this->configuration); 64 64 $generatorManager->generate('sfPropelFormGenerator', array('connection' => $options['connection'])); 65 65 } branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataDumpTask.class.php
r7454 r7618 69 69 protected function execute($arguments = array(), $options = array()) 70 70 { 71 $configuration = sfApplicationConfiguration::getForApplication($arguments['application'], $options['env'], true); 72 73 $databaseManager = new sfDatabaseManager($configuration); 74 71 75 $filename = $arguments['target']; 72 73 $this->bootstrapSymfony($arguments['application'], $options['env'], true);74 75 $databaseManager = new sfDatabaseManager();76 77 76 if (!is_null($filename) && !sfToolkit::isPathAbsolute($filename)) 78 77 { branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataLoadTask.class.php
r7454 r7618 71 71 protected function execute($arguments = array(), $options = array()) 72 72 { 73 $this->bootstrapSymfony($arguments['application'], $options['env'], true);74 75 73 if (count($options['dir'])) 76 74 { … … 86 84 } 87 85 88 $databaseManager = new sfDatabaseManager(); 86 $configuration = sfApplicationConfiguration::getForApplication($arguments['application'], $options['env'], true); 87 88 $databaseManager = new sfDatabaseManager($configuration); 89 89 90 90 $data = new sfPropelData(); branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelGenerateCrudTask.class.php
r7454 r7618 93 93 $tmpDir = sfConfig::get('sf_cache_dir').DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.md5(uniqid(rand(), true)); 94 94 sfConfig::set('sf_module_cache_dir', $tmpDir); 95 $generatorManager = new sfGeneratorManager( );95 $generatorManager = new sfGeneratorManager($this->configuration); 96 96 $generatorManager->generate('sfPropelCrudGenerator', array( 97 97 'model_class' => $arguments['model'], … … 137 137 // create basic application structure 138 138 $finder = sfFinder::type('any')->ignore_version_control()->discard('.sf'); 139 $dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelCrud', $options['theme']);139 $dirs = $this->configuration->getGeneratorSkeletonDirs('sfPropelCrud', $options['theme']); 140 140 foreach ($dirs as $dir) 141 141 { branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInitAdminTask.class.php
r7416 r7618 79 79 // create module structure 80 80 $finder = sfFinder::type('any')->ignore_version_control()->discard('.sf'); 81 $dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelAdmin', $options['theme']);81 $dirs = $this->configuration->getGeneratorSkeletonDirs('sfPropelAdmin', $options['theme']); 82 82 foreach ($dirs as $dir) 83 83 { branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/bootstrap/functional.php
r7196 r7618 19 19 $root_dir = realpath(dirname(__FILE__).sprintf('/../%s/fixtures', isset($type) ? $type : 'functional')); 20 20 } 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);25 21 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'; 23 require $root_dir.'/lib/'.$class.'.class.php'; 24 $configuration = new $class('test', isset($debug) ? $debug : true); 25 sfContext::createInstance($configuration); 28 26 29 27 // remove all cache … … 77 75 78 76 // initialize database manager 79 $databaseManager = new sfDatabaseManager( );77 $databaseManager = new sfDatabaseManager($configuration); 80 78 81 79 // cleanup database branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/backendTestBrowser.class.php
r6487 r7618 46 46 $params['moduleName'] = $this->moduleName; 47 47 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 } 50 53 file_put_contents(sprintf('%s/modules_%s_config_generator.yml.php', sfConfig::get('sf_config_cache_dir'), $this->moduleName), '<?php '.$generatorManager->generate('sfPropelAdminGenerator', $params)); 51 54 branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/symfony
r7454 r7618 11 11 12 12 chdir(dirname(__FILE__)); 13 include('config/config.php'); 14 include($sf_symfony_lib_dir.'/command/cli.php'); 13 require_once(dirname(__FILE__).'/lib/ProjectConfiguration.class.php'); 14 $configuration = new ProjectConfiguration(); 15 include($configuration->getSymfonyLibDir().'/command/cli.php'); branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/functional.php
r5262 r7618 4 4 * This file is part of the symfony package. 5 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 6 * 7 7 * For the full copyright and license information, please view the LICENSE 8 8 * file that was distributed with this source code. … … 14 14 $traces = debug_backtrace(); 15 15 $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); 17 19 } 18 20 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'; 22 require_once(dirname(__FILE__).'/../../lib/'.$class.'.class.php'); 24 23 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); 25 sfContext::createInstance($configuration); 27 26 28 27 // remove all cache branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/unit.php
r5125 r7618 10 10 11 11 $_test_dir = realpath(dirname(__FILE__).'/..'); 12 define('SF_ROOT_DIR', realpath($_test_dir.'/..'));13 12 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'); 13 require_once(dirname(__FILE__).'/../../lib/ProjectConfiguration.class.php'); 14 $configuration = new ProjectConfiguration(realpath($_test_dir.'/..')); 15 include($configuration->getSymfonyLibDir().'/vendor/lime/lime.php'); branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/backend_dev.php
r5125 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'backend'); 5 define('SF_ENVIRONMENT', 'dev'); 6 define('SF_DEBUG', true); 3 require_once(dirname(__FILE__).'/../lib/backendConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud.php
r5125 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'crud'); 5 define('SF_ENVIRONMENT', 'prod'); 6 define('SF_DEBUG', false); 3 require_once(dirname(__FILE__).'/../lib/crudConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud_dev.php
r5125 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'crud'); 5 define('SF_ENVIRONMENT', 'dev'); 6 define('SF_DEBUG', true); 3 require_once(dirname(__FILE__).'/../lib/crudConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/index.php
r5125 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'backend'); 5 define('SF_ENVIRONMENT', 'prod'); 6 define('SF_DEBUG', false); 3 require_once(dirname(__FILE__).'/../lib/backendConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/lib/routing/sfPatternRouting.class.php
r7527 r7618 77 77 public function loadConfiguration() 78 78 { 79 if ($config = sfCon figCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/routing.yml', true))79 if ($config = sfContext::getInstance()->getConfigCache()->checkConfig('config/routing.yml', true)) 80 80 { 81 81 require($config); … … 428 428 429 429 // 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);')))) 431 431 { 432 432 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 69 69 $this->checkAppExists($application); 70 70 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 84 72 $browser = new sfBrowser(); 85 73 foreach($uris as $uri) … … 89 77 90 78 // 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'); 94 81 95 82 $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 112 112 )); 113 113 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 114 118 $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); 115 119 $fixPerms->setCommandApplication($this->commandApplication); branches/dwhittle/1.1/lib/task/generator/sfGenerateProjectTask.class.php
r7416 r7618 67 67 } 68 68 69 // Create basic project structure69 // create basic project structure 70 70 $finder = sfFinder::type('any')->ignore_version_control()->discard('.sf'); 71 71 $this->getFilesystem()->mirror(dirname(__FILE__).DIRECTORY_SEPARATOR.'skeleton'.DIRECTORY_SEPARATOR.'project', sfConfig::get('sf_root_dir'), $finder); 72 72 73 73 // 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 )); 80 81 81 82 $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); branches/dwhittle/1.1/lib/task/generator/skeleton/app/web/index.php
r7462 r7618 1 1 <?php 2 2 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##); 3 require_once(dirname(__FILE__).'/../lib/##APP_NAME##Configuration.class.php'); 7 4 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##); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/lib/task/generator/skeleton/project/symfony
r7349 r7618 11 11 12 12 chdir(dirname(__FILE__)); 13 include('config/config.php'); 14 include($sf_symfony_lib_dir.'/command/cli.php'); 13 require_once(dirname(__FILE__).'/lib/ProjectConfiguration.class.php'); 14 $configuration = new ProjectConfiguration(); 15 include($configuration->getSymfonyLibDir().'/command/cli.php'); branches/dwhittle/1.1/lib/task/generator/skeleton/project/test/bootstrap/functional.php
r7310 r7618 19 19 } 20 20 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'; 22 require_once(dirname(__FILE__).'/../../lib/'.$class.'.class.php'); 26 23 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); 25 sfContext::createInstance($configuration); 29 26 30 27 // remove all cache branches/dwhittle/1.1/lib/task/generator/skeleton/project/test/bootstrap/unit.php
r7310 r7618 10 10 11 11 $_test_dir = realpath(dirname(__FILE__).'/..'); 12 define('SF_ROOT_DIR', realpath($_test_dir.'/..'));13 12 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'); 13 require_once(dirname(__FILE__).'/../../lib/ProjectConfiguration.class.php'); 14 $configuration = new ProjectConfiguration(realpath($_test_dir.'/..')); 15 include($configuration->getSymfonyLibDir().'/vendor/lime/lime.php'); branches/dwhittle/1.1/lib/task/i18n/sfI18nExtractTask.class.php
r7454 r7618 82 82 public function execute($arguments = array(), $options = array()) 83 83 { 84 $this->bootstrapSymfony($arguments['application'], 'dev', true);85 86 84 $this->logSection('i18n', sprintf('extracting i18n strings for the "%s" application', $arguments['application'])); 87 85 88 $extract = new sfI18nApplicationExtract( sfContext::getInstance()->getI18N(), $arguments['culture']);86 $extract = new sfI18nApplicationExtract(new sfI18N($this->configuration, new sfNoCache()), $arguments['culture']); 89 87 90 88 $extract->extract(); branches/dwhittle/1.1/lib/task/i18n/sfI18nFindTask.class.php
r7416 r7618 46 46 { 47 47 $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']);50 48 51 49 // Look in templates branches/dwhittle/1.1/lib/task/project/sfProjectClearControllersTask.class.php
r7416 r7618 65 65 foreach ($finder->in(sfConfig::get('sf_web_dir')) as $controller) 66 66 { 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); 70 68 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)) 73 70 { 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 } 75 76 } 76 77 } branches/dwhittle/1.1/lib/task/project/sfProjectFreezeTask.class.php
r7416 r7618 75 75 } 76 76 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']; 79 79 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)); 82 82 83 83 $this->getFilesystem()->mkdirs($sf_lib_dir.DIRECTORY_SEPARATOR.'symfony'); 84 84 $this->getFilesystem()->mkdirs($sf_data_dir.DIRECTORY_SEPARATOR.'symfony'); 85 85 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); 89 89 90 90 $this->getFilesystem()->rename($sf_data_dir.DIRECTORY_SEPARATOR.'symfony'.DIRECTORY_SEPARATOR.'web'.DIRECTORY_SEPARATOR.'sf', $sf_web_dir.DIRECTORY_SEPARATOR.'sf'); 91 91 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); 95 98 } 96 99 97 p rotected function changeSymfonyDirs($symfony_lib_dir)100 public function excludeTests($dir, $entry) 98 101 { 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/'); 104 103 } 105 104 } branches/dwhittle/1.1/lib/task/project/sfProjectUnfreezeTask.class.php
r7416 r7618 56 56 } 57 57 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 } 59 67 60 68 $finder = sfFinder::type('any'); … … 65 73 $this->getFilesystem()->remove($finder->in($sf_web_dir.DIRECTORY_SEPARATOR.'sf')); 66 74 $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);76 75 } 77 76 } branches/dwhittle/1.1/lib/task/project/upgrade1.1/sfConfigUpgrade.class.php
r7416 r7618 21 21 public function upgrade() 22 22 { 23 $this->checkConfigFiles(); 24 $this->upgradeFrontControllers(); 25 $this->upgradeConfigurationClasses(); 26 } 27 28 protected function checkConfigFiles() 29 { 23 30 $finder = $this->getFinder('file')->name('config.php'); 24 31 foreach ($finder->in($this->getProjectConfigDirectories()) as $file) 25 32 { 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 { 26 46 $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\'')) 29 50 { 30 $this->logSection('config', sprintf('Migrating %s', $file)); 31 file_put_contents($file, $content); 51 continue; 32 52 } 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 81 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 82 define('SF_APP', '$app'); 83 define('SF_ENVIRONMENT', '$environment'); 84 define('SF_DEBUG', $debug); 85 86 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 87 88 sfContext::getInstance()->getController()->dispatch(); 89 90 EOF; 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)); 33 125 } 34 126 } branches/dwhittle/1.1/lib/task/project/upgrade1.1/sfUpgrade.class.php
r7416 r7618 100 100 ); 101 101 } 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 } 102 112 } branches/dwhittle/1.1/lib/task/sfBaseTask.class.php
r7416 r7618 19 19 abstract class sfBaseTask extends sfCommandApplicationTask 20 20 { 21 protected 22 $configuration = null; 23 21 24 /** 22 25 * @see sfTask … … 28 31 $this->checkProjectExists(); 29 32 30 try 33 $this->configuration = new sfProjectConfiguration(getcwd()); 34 35 $application = $commandManager->getArgumentSet()->hasArgument('application') ? $commandManager->getArgumentValue('application') : null; 36 if (!is_null($application)) 31 37 { 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); 39 42 } 40 43 … … 62 65 63 66 return $this->filesystem; 64 }65 66 /**67 * Bootstraps a symfony application.68 *69 * @param string The application name70 * @param string The environment name71 * @param Boolean Whether to bootstrap the symfony application in debug mode72 */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();88 67 } 89 68 branches/dwhittle/1.1/lib/task/test/sfTestFunctionalTask.class.php
r6932 r7618 63 63 foreach ($arguments['controller'] as $controller) 64 64 { 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)); 66 66 foreach ($files as $file) 67 67 { … … 75 75 76 76 $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; 78 78 79 79 // register functional tests branches/dwhittle/1.1/lib/task/test/sfTestUnitTask.class.php
r6932 r7618 70 70 71 71 $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'; 73 73 74 74 // register unit tests branches/dwhittle/1.1/lib/util/sfBrowser.class.php
r6846 r7618 219 219 } 220 220 221 ob_start(); 222 221 223 // 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); 225 225 226 226 // launch request via controller … … 232 232 233 233 // dispatch our request 234 ob_start();235 234 $controller->dispatch(); 235 236 236 $retval = ob_get_clean(); 237 237 … … 366 366 367 367 /** 368 * Gets context. 368 * Returns the current application context. 369 * 370 * @param Boolean true to force context reload, false otherwise 369 371 * 370 372 * @return sfContext 371 373 */ 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 374 383 return $this->context; 375 384 } branches/dwhittle/1.1/lib/util/sfContext.class.php
r7574 r7618 24 24 { 25 25 protected 26 $dispatcher = null, 27 $factories = array(); 26 $dispatcher = null, 27 $configuration = null, 28 $factories = array(); 28 29 29 30 protected static … … 32 33 33 34 /** 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__) 77 44 { 78 45 if (is_null($name)) 79 46 { 80 $name = self::$current; 81 } 47 $name = $configuration->getApplication(); 48 } 49 50 self::$current = $name; 82 51 83 52 if (!isset(self::$instances[$name])) … … 90 59 } 91 60 92 self::$instances[$name]->initialize( );61 self::$instances[$name]->initialize($configuration); 93 62 } 94 63 … … 97 66 98 67 /** 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 /** 99 119 * Checks to see if there has been a context created 100 120 * 101 * @param string The name of the sfContext to check for121 * @param string The name of the sfContext to check for 102 122 * 103 123 * @return boolean True is instanced, otherwise false … … 115 135 116 136 /** 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 /** 118 165 * Sets the current context to something else 119 166 * … … 124 171 { 125 172 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; 126 183 } 127 184 … … 341 398 342 399 /** 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 /** 343 410 * Gets an object from the current context. 344 411 * branches/dwhittle/1.1/lib/view/sfPHPView.class.php
r7416 r7618 104 104 105 105 // 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')); 108 107 109 108 // decorator configuration … … 113 112 if (!$this->directory) 114 113 { 115 $this->setDirectory( sfLoader::getTemplateDir($this->moduleName, $this->getTemplate()));114 $this->setDirectory($this->context->getConfiguration()->getTemplateDir($this->moduleName, $this->getTemplate())); 116 115 } 117 116 } branches/dwhittle/1.1/lib/view/sfPartialView.class.php
r7416 r7618 40 40 else 41 41 { 42 $this->setDirectory( sfLoader::getTemplateDir($this->moduleName, $this->getTemplate()));42 $this->setDirectory($this->context->getConfiguration()->getTemplateDir($this->moduleName, $this->getTemplate())); 43 43 } 44 44 } branches/dwhittle/1.1/lib/view/sfViewCacheManager.class.php
r6602 r7618 194 194 if (!isset($this->loaded[$moduleName])) 195 195 { 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')); 197 197 $this->loaded[$moduleName] = true; 198 198 } branches/dwhittle/1.1/test/bin/loc.php
r7377 r7618 5 5 require_once($root_dir.'/lib/util/sfFinder.class.php'); 6 6 7 require_once($root_dir.'/lib/util/sfCoreAutoload.class.php'); 8 require_once($root_dir.'/lib/util/sfCore.class.php'); 7 require_once($root_dir.'/lib/autoload/sfCoreAutoload.class.php'); 9 8 $version = SYMFONY_VERSION; 10 9 branches/dwhittle/1.1/test/bootstrap/functional.php
r7195 r7618 20 20 $root_dir = realpath(dirname(__FILE__).sprintf('/../%s/fixtures/project', isset($type) ? $type : 'functional')); 21 21 } 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);26 22 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'; 24 require $root_dir.'/lib/'.$class.'.class.php'; 25 $configuration = new $class('test', isset($debug) ? $debug : true); 26 sfContext::createInstance($configuration); 29 27 30 28 // remove all cache branches/dwhittle/1.1/test/functional/fixtures/project/symfony
r7454 r7618 11 11 12 12 chdir(dirname(__FILE__)); 13 include('config/config.php'); 14 include($sf_symfony_lib_dir.'/command/cli.php'); 13 require_once(dirname(__FILE__).'/lib/ProjectConfiguration.class.php'); 14 $configuration = new ProjectConfiguration(); 15 include($configuration->getSymfonyLibDir().'/command/cli.php'); branches/dwhittle/1.1/test/functional/fixtures/project/test/bootstrap/functional.php
r5262 r7618 4 4 * This file is part of the symfony package. 5 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 6 * 7 7 * For the full copyright and license information, please view the LICENSE 8 8 * file that was distributed with this source code. … … 14 14 $traces = debug_backtrace(); 15 15 $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); 17 19 } 18 20 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'; 22 require_once(dirname(__FILE__).'/../../lib/'.$class.'.class.php'); 24 23 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); 25 sfContext::createInstance($configuration); 27 26 28 27 // remove all cache branches/dwhittle/1.1/test/functional/fixtures/project/test/bootstrap/unit.php
r2594 r7618 10 10 11 11 $_test_dir = realpath(dirname(__FILE__).'/..'); 12 define('SF_ROOT_DIR', realpath($_test_dir.'/..'));13 12 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'); 13 require_once(dirname(__FILE__).'/../../lib/ProjectConfiguration.class.php'); 14 $configuration = new ProjectConfiguration(realpath($_test_dir.'/..')); 15 include($configuration->getSymfonyLibDir().'/vendor/lime/lime.php'); branches/dwhittle/1.1/test/functional/fixtures/project/web/cache.php
r2369 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'cache'); 5 define('SF_ENVIRONMENT', 'prod'); 6 define('SF_DEBUG', false); 3 require_once(dirname(__FILE__).'/../lib/cacheConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/test/functional/fixtures/project/web/cache_dev.php
r2369 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'cache'); 5 define('SF_ENVIRONMENT', 'dev'); 6 define('SF_DEBUG', true); 3 require_once(dirname(__FILE__).'/../lib/cacheConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/test/functional/fixtures/project/web/frontend_dev.php
r2369 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'frontend'); 5 define('SF_ENVIRONMENT', 'dev'); 6 define('SF_DEBUG', true); 3 require_once(dirname(__FILE__).'/../lib/frontendConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/test/functional/fixtures/project/web/i18n.php
r2823 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'i18n'); 5 define('SF_ENVIRONMENT', 'prod'); 6 define('SF_DEBUG', false); 3 require_once(dirname(__FILE__).'/../lib/i18nConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/test/functional/fixtures/project/web/i18n_dev.php
r2823 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'i18n'); 5 define('SF_ENVIRONMENT', 'dev'); 6 define('SF_DEBUG', true); 3 require_once(dirname(__FILE__).'/../lib/i18nConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/test/functional/fixtures/project/web/index.php
r2369 r7618 1 1 <?php 2 2 3 define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 4 define('SF_APP', 'frontend'); 5 define('SF_ENVIRONMENT', 'prod'); 6 define('SF_DEBUG', false); 3 require_once(dirname(__FILE__).'/../lib/frontendConfiguration.class.php'); 7 4 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); 6 sfContext::createInstance($configuration)->dispatch(); branches/dwhittle/1.1/test/other/tasksTest.php
r7503 r7618 122 122 123 123 $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'); 125 125 126 126 $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'); 128 128 129 129 $c->shutdown(); branches/dwhittle/1.1/test/unit/config/sfConfigCacheTest.php
r4149 r7618 10 10 11 11 require_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 18 18 } 19 19 20 $manager = new sfGeneratorManager(); 20 class ProjectConfiguration extends sfProjectConfiguration 21 { 22 } 23 24 $manager = new sfGeneratorManager(new ProjectConfiguration()); 21 25 $generator = new myGenerator($manager); branches/dwhittle/1.1/test/unit/i18n/extract/sfI18nExtractTest.php
r7524 r7618 13 13 $t = new lime_test(3, new lime_output_color()); 14 14 15 class sfLoader15 class ProjectConfiguration extends sfProjectConfiguration 16 16 { 17 static public function getI18NGlobalDirs() 17 } 18 19 class TestConfiguration extends sfApplicationConfiguration 20 { 21 public function getI18NGlobalDirs() 18 22 { 19 23 return array(dirname(__FILE__).'/../fixtures'); … … 21 25 } 22 26 23 $ dispatcher = new sfEventDispatcher();27 $configuration = new TestConfiguration('test', true); 24 28 $cache = new sfNoCache(); 25 $i18n = new sfI18N($dispatcher, array('cache' => $cache)); 29 30 $i18n = new sfI18N($configuration, $cache); 26 31 27 32 class sfI18nExtractTest extends sfI18nExtract branches/dwhittle/1.1/test/unit/i18n/sfI18NTest.php
r7524 r7618 13 13 $t = new lime_test(19, new lime_output_color()); 14 14 15 class sfLoader15 class ProjectConfiguration extends sfProjectConfiguration 16 16 { 17 static public function getI18NGlobalDirs() 17 } 18 19 class TestConfiguration extends sfApplicationConfiguration 20 { 21 public function getI18NGlobalDirs() 18 22 { 19 23 return array(dirname(__FILE__).'/fixtures'); … … 21 25 } 22 26 23 $dispatcher = new sfEventDispatcher(); 27 $configuration = new TestConfiguration('test', true); 28 $dispatcher = $configuration->getEventDispatcher(); 24 29 $cache = new sfNoCache(); 25 30 26 31 // ->initialize() 27 32 $t->diag('->initialize()'); 28 $i18n = new sfI18N($ dispatcher, array('cache' => $cache));33 $i18n = new sfI18N($configuration, $cache); 29 34 $dispatcher->notify(new sfEvent(null, 'user.change_culture', array('culture' => 'fr'))); 30 35 $t->is($i18n->getCulture(), 'fr', '->initialize() connects to the user.change_culture event'); … … 32 37 // ->getCulture() ->setCulture() 33 38 $t->diag('->getCulture() ->setCulture()'); 34 $i18n = new sfI18N($ dispatcher, array('cache' => $cache));39 $i18n = new sfI18N($configuration, $cache); 35 40 $t->is($i18n->getCulture(), 'en', '->getCulture() returns the current culture'); 36 41 $i18n->setCulture('fr'); … … 40 45 $t->diag('->__()'); 41 46 sfConfig::set('sf_charset', 'UTF-8'); 42 $i18n = new sfI18N($ dispatcher, array('cache' => $cache,'culture' => 'fr'));47 $i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); 43 48 $t->is($i18n->__('an english sentence'), 'une phrase en français', '->__() translates a string'); 44 49 $args = array('%timestamp%' => $timestamp = time()); … … 50 55 51 56 // debug 52 $i18n = new sfI18N($ dispatcher, array('cache' => $cache,'debug' => true));57 $i18n = new sfI18N($configuration, $cache, array('debug' => true)); 53 58 $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' => '#')); 55 60 $t->is($i18n->__('unknown'), '-unknown#', '->initialize() can change the default prefix and suffix dor untranslated strings'); 56 61 57 62 // ->getCountry() 58 63 $t->diag('->getCountry()'); 59 $i18n = new sfI18N($ dispatcher, array('cache' => $cache,'culture' => 'fr'));64 $i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); 60 65 $t->is($i18n->getCountry('FR'), 'France', '->getCountry() returns the name of a country for the current culture'); 61 66 $t->is($i18n->getCountry('FR', 'es'), 'Francia', '->getCountry() takes an optional culture as its second argument'); … … 63 68 // ->getNativeName() 64 69 $t->diag('->getNativeName()'); 65 $i18n = new sfI18N($ dispatcher, array('cache' => $cache,'culture' => 'fr'));70 $i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); 66 71 $t->is($i18n->getNativeName('fr'), 'français', '->getNativeName() returns the name of a culture'); 67 72 68 73 // ->getTimestampForCulture() 69 74 $t->diag('->getTimestampForCulture()'); 70 $i18n = new sfI18N($ dispatcher, array('cache' => $cache,'culture' => 'fr'));75 $i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); 71 76 $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'); 72 77 $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'); … … 75 80 // ->getDateForCulture() 76 81 $t->diag('->getDateForCulture()'); 77 $i18n = new sfI18N($ dispatcher, array('cache' => $cache,'culture' => 'fr'));82 $i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); 78 83 $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'); 79 84 $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 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(127, new lime_output_color()); 13 14 $t = new lime_test(128, new lime_output_color()); 14 15 15 16 class sfPatternRoutingTest extends sfPatternRouting … … 485 486 } 486 487 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(); 497 try 498 { 499 $r->generate('', $params); 500 $t->fail('->generate() throws a sfConfigurationException if no route matches the params'); 501 } 502 catch (sfConfigurationException $e) 503 { 504 $t->pass('->generate() throws a sfConfigurationException if no route matches the params'); 505 } 487 506 488 507 // no route matches … … 491 510 try 492 511 { 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 try503 {504 512 $r->parse('/test'); 505 513 $t->fail('->parse() routes that do not match throw sfError404Exception'); branches/dwhittle/1.1/test/unit/sfContextMock.class.php
r7578 r7618 9 9 */ 10 10 11 require_once(sfConfig::get('sf_symfony_lib_dir').'/config/sfProjectConfiguration.class.php'); 12 class ProjectConfiguration extends sfProjectConfiguration 13 { 14 15 } 16 17 class ApplicationConfiguration extends ProjectConfiguration 18 { 19 20 } 21 11 22 class sfContext 12 23 { … … 15 26 16 27 public 28 $configuration = null, 17 29 $request = null, 18 30 $response = null, … … 21 33 $user = null, 22 34 $storage = null, 23 $i18n = null; 35 $i18n = null, 36 $cache = null; 24 37 25 38 protected … … 35 48 self::$instance->storage = new sfSessionTestStorage(array('session_path' => self::$instance->sessionPath)); 36 49 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(); 38 53 39 54 foreach ($factories as $type => $class) … … 106 121 } 107 122 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 108 138 public function inject($type, $class, $parameters = array()) 109 139 { … … 121 151 break; 122 152 case 'i18n': 123 $object = new $class($this-> dispatcher, $parameters);153 $object = new $class($this->configuration, $this->cache, $parameters); 124 154 break; 125 155 default: branches/dwhittle/1.1/test/unit/task/cache/sfCacheClearTaskTest.php
r6860 r7618 13 13 $t = new lime_test(2, new lime_output_color()); 14 14 15 class ProjectConfiguration extends sfProjectConfiguration 16 { 17 } 18 19 class TestConfiguration extends sfApplicationConfiguration 20 { 21 } 22 23 $configuration = new TestConfiguration('test', true, sfConfig::get('sf_root_dir')); 15 24 $dispatcher = new sfEventDispatcher(); 16 25 $formatter = new sfFormatter(); … … 20 29 $task = new sfGenerateAppTask($dispatcher, $formatter); 21 30 $task->run(array('frontend')); 22 23 sfCore::initDirectoryLayout(sfConfig::get('sf_root_dir'), 'frontend', 'dev');24 31 25 32 // Put something in the cache branches/dwhittle/1.1/test/unit/util/sfContextTest.php
r4494 r7618 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(8, new lime_output_color()); 13 // FIXME 14 $t = new lime_test(0, new lime_output_color()); 14 15 15 16 class myContext extends sfContext 16 17 { 17 public function initialize( )18 public function initialize(sfApplicationConfiguration $configuration) 18 19 { 19 20 } 20 21 } 21 22 23 class ProjectConfiguration extends sfProjectConfiguration 24 { 25 } 26 27 class frontendConfiguration extends sfApplicationConfiguration 28 { 29 } 30 /* 22 31 // ::getInstance() 23 32 $t->diag('::getInstance()'); … … 52 61 $t->pass('->get() throws an sfException if no object is stored for the given name'); 53 62 } 63 */

