Changeset 7614
- Timestamp:
- 02/26/08 18:38:26 (1 year ago)
- Files:
-
- branches/1.1/UPGRADE (modified) (3 diffs)
- branches/1.1/lib/action/sfAction.class.php (modified) (1 diff)
- branches/1.1/lib/autoload/sfAutoload.class.php (modified) (2 diffs)
- branches/1.1/lib/autoload/sfCoreAutoload.class.php (modified) (5 diffs)
- branches/1.1/lib/command/sfSymfonyCommandApplication.class.php (modified) (4 diffs)
- branches/1.1/lib/config/config/core_compile.yml (modified) (2 diffs)
- branches/1.1/lib/config/sfApplicationConfiguration.class.php (added)
- branches/1.1/lib/config/sfCompileConfigHandler.class.php (modified) (2 diffs)
- branches/1.1/lib/config/sfConfigCache.class.php (modified) (4 diffs)
- branches/1.1/lib/config/sfFactoryConfigHandler.class.php (modified) (1 diff)
- branches/1.1/lib/config/sfGeneratorConfigHandler.class.php (modified) (1 diff)
- branches/1.1/lib/config/sfLoader.class.php (modified) (2 diffs)
- branches/1.1/lib/config/sfProjectConfiguration.class.php (added)
- branches/1.1/lib/controller/default/templates/moduleSuccess.php (modified) (1 diff)
- branches/1.1/lib/controller/sfController.class.php (modified) (3 diffs)
- branches/1.1/lib/database/sfDatabaseManager.class.php (modified) (4 diffs)
- branches/1.1/lib/filter/sfFilterChain.class.php (modified) (1 diff)
- branches/1.1/lib/generator/sfCrudGenerator.class.php (modified) (1 diff)
- branches/1.1/lib/generator/sfGenerator.class.php (modified) (1 diff)
- branches/1.1/lib/generator/sfGeneratorManager.class.php (modified) (1 diff)
- branches/1.1/lib/i18n/extract/sfI18nModuleExtract.class.php (modified) (1 diff)
- branches/1.1/lib/i18n/sfI18N.class.php (modified) (6 diffs)
- branches/1.1/lib/plugins/sfCompat10Plugin/config/config.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfCompat10Plugin/lib/filter/sfValidationExecutionFilter.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfCompat10Plugin/lib/helper/PartialHelper.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfCompat10Plugin/lib/view/sfMailView.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/bootstrap/functional.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/apps/frontend/config/config.php (deleted)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/config/config.php (deleted)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/lib/ProjectConfiguration.class.php (added)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/lib/frontendConfiguration.class.php (added)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/symfony (modified) (1 diff)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/functional.php (modified) (2 diffs)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/unit.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/frontend_dev.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/index.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/config/config.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelCrudGenerator.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelAutoload.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelData.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelManyToMany.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBaseTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildFormsTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataDumpTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataLoadTask.class.php (modified) (2 diffs)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelGenerateCrudTask.class.php (modified) (2 diffs)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInitAdminTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/test/bootstrap/functional.php (modified) (2 diffs)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/backendTestBrowser.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/apps/backend/config/config.php (deleted)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/apps/crud/config/config.php (deleted)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/config/config.php (deleted)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/ProjectConfiguration.class.php (added)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/backendConfiguration.class.php (added)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/crudConfiguration.class.php (added)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/symfony (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/functional.php (modified) (2 diffs)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/unit.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/backend_dev.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud_dev.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/index.php (modified) (1 diff)
- branches/1.1/lib/routing/sfPatternRouting.class.php (modified) (1 diff)
- branches/1.1/lib/task/generator/sfGenerateAppTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/generator/sfGenerateProjectTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/generator/skeleton/app/app/config/config.php (deleted)
- branches/1.1/lib/task/generator/skeleton/app/lib (added)
- branches/1.1/lib/task/generator/skeleton/app/lib/ApplicationConfiguration.class.php (added)
- branches/1.1/lib/task/generator/skeleton/app/web/index.php (modified) (1 diff)
- branches/1.1/lib/task/generator/skeleton/project/config/config.php (deleted)
- branches/1.1/lib/task/generator/skeleton/project/lib/ProjectConfiguration.class.php (added)
- branches/1.1/lib/task/generator/skeleton/project/symfony (modified) (1 diff)
- branches/1.1/lib/task/generator/skeleton/project/test/bootstrap/functional.php (modified) (1 diff)
- branches/1.1/lib/task/generator/skeleton/project/test/bootstrap/unit.php (modified) (1 diff)
- branches/1.1/lib/task/i18n/sfI18nExtractTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/i18n/sfI18nFindTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/project/sfProjectClearControllersTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/project/sfProjectFreezeTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/project/sfProjectUnfreezeTask.class.php (modified) (2 diffs)
- branches/1.1/lib/task/project/upgrade1.1/sfAutoloadingUpgrade.class.php (deleted)
- branches/1.1/lib/task/project/upgrade1.1/sfConfigUpgrade.class.php (modified) (1 diff)
- branches/1.1/lib/task/project/upgrade1.1/sfTestUpgrade.class.php (added)
- branches/1.1/lib/task/project/upgrade1.1/sfUpgrade.class.php (modified) (1 diff)
- branches/1.1/lib/task/sfBaseTask.class.php (modified) (3 diffs)
- branches/1.1/lib/util/sfBrowser.class.php (modified) (3 diffs)
- branches/1.1/lib/util/sfContext.class.php (modified) (7 diffs)
- branches/1.1/lib/util/sfCore.class.php (deleted)
- branches/1.1/lib/view/sfPHPView.class.php (modified) (2 diffs)
- branches/1.1/lib/view/sfPartialView.class.php (modified) (1 diff)
- branches/1.1/lib/view/sfViewCacheManager.class.php (modified) (1 diff)
- branches/1.1/test/bin/loc.php (modified) (1 diff)
- branches/1.1/test/bootstrap/functional.php (modified) (1 diff)
- branches/1.1/test/functional/configTest.php (deleted)
- branches/1.1/test/functional/fixtures/project/apps/cache/config/config.php (deleted)
- branches/1.1/test/functional/fixtures/project/apps/frontend/config/config.php (deleted)
- branches/1.1/test/functional/fixtures/project/apps/i18n/config/config.php (deleted)
- branches/1.1/test/functional/fixtures/project/config/config.php (deleted)
- branches/1.1/test/functional/fixtures/project/lib/ProjectConfiguration.class.php (added)
- branches/1.1/test/functional/fixtures/project/lib/cacheConfiguration.class.php (added)
- branches/1.1/test/functional/fixtures/project/lib/frontendConfiguration.class.php (added)
- branches/1.1/test/functional/fixtures/project/lib/i18nConfiguration.class.php (added)
- branches/1.1/test/functional/fixtures/project/symfony (modified) (1 diff)
- branches/1.1/test/functional/fixtures/project/test/bootstrap/functional.php (modified) (2 diffs)
- branches/1.1/test/functional/fixtures/project/test/bootstrap/unit.php (modified) (1 diff)
- branches/1.1/test/functional/fixtures/project/web/cache.php (modified) (1 diff)
- branches/1.1/test/functional/fixtures/project/web/cache_dev.php (modified) (1 diff)
- branches/1.1/test/functional/fixtures/project/web/frontend_dev.php (modified) (1 diff)
- branches/1.1/test/functional/fixtures/project/web/i18n.php (modified) (1 diff)
- branches/1.1/test/functional/fixtures/project/web/i18n_dev.php (modified) (1 diff)
- branches/1.1/test/functional/fixtures/project/web/index.php (modified) (1 diff)
- branches/1.1/test/other/tasksTest.php (modified) (1 diff)
- branches/1.1/test/unit/config/sfConfigCacheTest.php (modified) (1 diff)
- branches/1.1/test/unit/generator/sfGeneratorTest.php (modified) (1 diff)
- branches/1.1/test/unit/i18n/extract/sfI18nExtractTest.php (modified) (2 diffs)
- branches/1.1/test/unit/i18n/sfI18NTest.php (modified) (7 diffs)
- branches/1.1/test/unit/task/cache/sfCacheClearTaskTest.php (modified) (2 diffs)
- branches/1.1/test/unit/util/sfContextTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/UPGRADE
r7518 r7614 12 12 To upgrade a project: 13 13 14 * Upgrade symfony via PEAR or change your `config/config.php` 15 to update the symfony directory. 14 * If you don't use a SCM tool, please make a backup of your project. 15 As symfony replaces some files during the upgrade 16 (front controllers for example), you need a way to merge your 17 customizations after the upgrade. 16 18 17 19 * Update the `symfony` file located in the project root directory 18 by changing the line: 19 20 by changing those three lines: 21 22 [php] 23 chdir(dirname(__FILE__)); 24 include('config/config.php'); 20 25 include($sf_symfony_data_dir.'/bin/symfony.php'); 21 26 22 27 to 23 28 24 include($sf_symfony_lib_dir.'/command/cli.php'); 29 [php] 30 chdir(dirname(__FILE__)); 31 require_once(dirname(__FILE__).'/lib/ProjectConfiguration.class.php'); 32 $configuration = new ProjectConfiguration(); 33 include($configuration->getSymfonyLibDir().'/command/cli.php'); 34 35 You can also copy the skeleton file from the symfony project skeleton directly: 36 37 $ cp /path/to/symfony/lib/task/generator/skeleton/project/symfony symfony 38 39 * Create a `lib/ProjectConfiguration.class.php` file with the following content: 40 41 [php] 42 <?php 43 44 require_once '##SYMFONY_LIB_DIR##/autoload/sfCoreAutoload.class.php'; 45 sfCoreAutoload::register(); 46 47 class ProjectConfiguration extends sfProjectConfiguration 48 { 49 public function setup() 50 { 51 } 52 } 53 54 Then, replace `##SYMFONY_LIB_DIR##` with the path to the symfony 1.1 55 `lib/` directory. This is the new way to change the symfony version used 56 for your project. 57 58 You can also copy the skeleton file from the symfony project skeleton directly: 59 60 $ cp /path/to/symfony/lib/task/generator/skeleton/project/lib/ProjectConfiguration.class.php lib/ProjectConfiguration.class.php 25 61 26 62 * Launch the `project:upgrade1.1` task from your project directory … … 213 249 214 250 The `autoloading_function` setting in `settings.yml` is not used anymore. 215 You can register autoloading callables in the application `config.php`. 216 Here is the new default `config.php`: 217 218 [php] 219 <?php 220 221 // include project configuration 222 include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 223 224 // symfony bootstraping 225 require_once($sf_symfony_lib_dir.'/util/sfCore.class.php'); 226 sfCore::bootstrap($sf_symfony_lib_dir, $sf_symfony_data_dir); 227 228 // insert your own autoloading callables here 229 230 if (sfConfig::get('sf_debug')) 231 { 232 spl_autoload_register(array('sfAutoload', 'autoloadAgain')); 233 } 251 You can register autoloading callables in your application configuration class. 234 252 235 253 Thanks to the new `sfAutoload::autoloadAgain()` method, you won't need to clear 236 254 the cache when you add or move classes in your project. This method will 237 255 automatically find the changes and flush the autoloading cache. 238 239 The `project:upgrade1.1` task makes all those changes for you.240 256 241 257 VERSION … … 466 482 467 483 The symfony core has been upgraded to take these changes into account. 484 485 sfLoader 486 -------- 487 488 All `sfLoader` static methods (except `::getHelperDirs()` and `::loadHelpers()`) 489 have been moved to the `sfProjectConfiguration` and `sfApplicationConfiguration` 490 classes: 491 492 * `sfProjectConfiguration`: 493 * `->getGeneratorSkeletonDirs()` 494 * `->getGeneratorTemplate()` 495 * `->getGeneratorTemplateDirs()` 496 * `->getModelDirs()` 497 498 * `sfApplicationConfiguration`: 499 * `->getControllerDirs()` 500 * `->getTemplateDirs()` 501 * `->getTemplateDir()` 502 * `->getTemplatePath()` 503 * `->getI18NGlobalDirs()` 504 * `->getI18NDirs()` 505 * `->getConfigPaths()` 506 507 sfCore 508 ------ 509 510 The `sfCore` has been removed. The code has been moved to `sfProjectConfiguration`, 511 `sfApplicationConfiguration`, and `sfContext` classes. 512 513 Front Controllers 514 ----------------- 515 516 All front controllers have to be upgraded. The SF_DEBUG, SF_APP, SF_ENVIRONMENT, 517 and SF_ROOT_DIR constants are gone. If you use some of these constants in your 518 project, please use their sfConfig::get('') counterparts: 519 520 *Old* | *New* 521 ----------------- | --------------------------------- 522 `SF_ROOT_DIR` | `sfConfig::get('sf_root_dir')` 523 `SF_ENVIRONMENT` | `sfConfig::get('sf_environment')` 524 `SF_APP` | `sfConfig::get('sf_app')` 525 `SF_DEBUG` | `sfConfig::get('sf_debug')` 526 527 The `project:upgrade1.1` task upgrades all front controllers for you. 528 If you made some customizations, symfony will issue a warning and won't 529 upgrade them automatically. You can then copy the default skeleton from 530 symfony: /path/to/symfony/lib/task/generator/skeleton/app/web/index.php 531 532 config.php 533 ---------- 534 535 All `config.php` files have been removed. The are replaced by the `ProjectConfiguration` 536 class and the application configuration classes. 537 538 If you've added some cutomizations in `config.php` files, you will have to migrate them 539 to those new classes. branches/1.1/lib/action/sfAction.class.php
r6668 r7614 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/1.1/lib/autoload/sfAutoload.class.php
r7247 r7614 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/1.1/lib/autoload/sfCoreAutoload.class.php
r7452 r7614 158 158 'sfFormatter' => 'command', 159 159 'sfSymfonyCommandApplication' => 'command', 160 'sfApplicationConfiguration' => 'config', 160 161 'sfAutoloadConfigHandler' => 'config', 161 162 'sfCacheConfigHandler' => 'config', … … 170 171 'sfGeneratorConfigHandler' => 'config', 171 172 'sfLoader' => 'config', 173 'sfProjectConfiguration' => 'config', 172 174 'sfRootConfigHandler' => 'config', 173 175 'sfRoutingConfigHandler' => 'config', … … 315 317 'sfProjectUnfreezeTask' => 'task/project', 316 318 'sfUpgradeTo11Task' => 'task/project', 317 'sfAutoloadingUpgrade' => 'task/project/upgrade1.1',318 319 'sfComponentUpgrade' => 'task/project/upgrade1.1', 319 320 'sfConfigFileUpgrade' => 'task/project/upgrade1.1', … … 325 326 'sfPropelUpgrade' => 'task/project/upgrade1.1', 326 327 'sfSingletonUpgrade' => 'task/project/upgrade1.1', 328 'sfTestUpgrade' => 'task/project/upgrade1.1', 327 329 'sfUpgrade' => 'task/project/upgrade1.1', 328 330 'sfWebDebugUpgrade' => 'task/project/upgrade1.1', … … 341 343 'sfCallable' => 'util', 342 344 'sfContext' => 'util', 343 'sfCore' => 'util',344 345 'sfDomCssSelector' => 'util', 345 346 'sfFinder' => 'util', branches/1.1/lib/command/sfSymfonyCommandApplication.class.php
r7467 r7614 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/1.1/lib/config/config/core_compile.yml
r5320 r7614 4 4 - %SF_SYMFONY_LIB_DIR%/action/sfActionStack.class.php 5 5 - %SF_SYMFONY_LIB_DIR%/action/sfActionStackEntry.class.php 6 #- %SF_SYMFONY_LIB_DIR%/config/sfLoader.class.php7 6 - %SF_SYMFONY_LIB_DIR%/controller/sfController.class.php 8 7 - %SF_SYMFONY_LIB_DIR%/database/sfDatabaseManager.class.php 9 - %SF_SYMFONY_LIB_DIR%/event/sfEvent.class.php10 - %SF_SYMFONY_LIB_DIR%/event/sfEventDispatcher.class.php11 8 - %SF_SYMFONY_LIB_DIR%/filter/sfFilter.class.php 12 9 - %SF_SYMFONY_LIB_DIR%/filter/sfCommonFilter.class.php … … 18 15 - %SF_SYMFONY_LIB_DIR%/storage/sfStorage.class.php 19 16 - %SF_SYMFONY_LIB_DIR%/user/sfUser.class.php 20 #- %SF_SYMFONY_LIB_DIR%/util/sfContext.class.php21 #- %SF_SYMFONY_LIB_DIR%/validator/sfValidatorManager.class.php22 #- %SF_SYMFONY_LIB_DIR%/util/sfParameterHolder.class.php23 17 - %SF_SYMFONY_LIB_DIR%/view/sfView.class.php 24 18 25 19 # these classes are optionals but very likely to be used (in web context) 26 #- %SF_SYMFONY_LIB_DIR%/controller/sfRouting.class.php27 20 - %SF_SYMFONY_LIB_DIR%/controller/sfWebController.class.php 28 21 - %SF_SYMFONY_LIB_DIR%/controller/sfFrontWebController.class.php branches/1.1/lib/config/sfCompileConfigHandler.class.php
r7370 r7614 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/1.1/lib/config/sfConfigCache.class.php
r7436 r7614 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/1.1/lib/config/sfFactoryConfigHandler.class.php
r7518 r7614 155 155 " \$class = sfConfig::get('sf_factory_i18n', '%s');\n". 156 156 "%s". 157 " \$this->factories['i18n'] = new \$class(\$this-> dispatcher, \$cache, %s);\n".157 " \$this->factories['i18n'] = new \$class(\$this->configuration, \$cache, %s);\n". 158 158 " }\n" 159 159 , $class, $cache, var_export($parameters, true) branches/1.1/lib/config/sfGeneratorConfigHandler.class.php
r6457 r7614 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/1.1/lib/config/sfLoader.class.php
r7302 r7614 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').'/model' ? sfConfig::get('sf_lib_dir').'/model' : 'lib/model'); // project29 if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/lib/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.'/'.sfConfig::get('sf_app_module_action_dir_name');47 48 $dirs = array();49 foreach (sfConfig::get('sf_module_dirs', array()) as $key => $value)50 {51 $dirs[$key.'/'.$suffix] = $value;52 }53 54 $dirs[sfConfig::get('sf_app_module_dir').'/'.$suffix] = false; // application55 56 if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/modules/'.$suffix))57 {58 $dirs = array_merge($dirs, array_combine($pluginDirs, array_fill(0, count($pluginDirs), true))); // plugins59 }60 61 $dirs[sfConfig::get('sf_symfony_lib_dir').'/controller/'.$suffix] = true; // core modules62 63 return $dirs;64 }65 66 /**67 * Gets directories where template files are stored for a given module.68 *69 * @param string The module name70 *71 * @return array An array of directories72 */73 static public function getTemplateDirs($moduleName)74 {75 $suffix = $moduleName.'/'.sfConfig::get('sf_app_module_template_dir_name');76 77 $dirs = array();78 foreach (sfConfig::get('sf_module_dirs', array()) as $key => $value)79 {80 $dirs[] = $key.'/'.$suffix;81 }82 83 $dirs[] = sfConfig::get('sf_app_module_dir').'/'.$suffix; // application84 85 if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/modules/'.$suffix))86 {87 $dirs = array_merge($dirs, $pluginDirs); // plugins88 }89 90 $dirs[] = sfConfig::get('sf_symfony_lib_dir').'/controller/'.$suffix; // core modules91 $dirs[] = sfConfig::get('sf_module_cache_dir').'/auto'.ucfirst($suffix); // generated templates in cache92 93 return $dirs;94 }95 96 /**97 * Gets the template directory to use for a given module and template file.98 *99 * @param string The module name100 * @param string The template file101 *102 * @return string A template directory103 */104 static public function getTemplateDir($moduleName, $templateFile)105 {106 $dirs = self::getTemplateDirs($moduleName);107 foreach ($dirs as $dir)108 {109 if (is_readable($dir.'/'.$templateFile))110 {111 return $dir;112 }113 }114 115 return null;116 }117 118 /**119 * Gets the template to use for a given module and template file.120 *121 * @param string The module name122 * @param string The template file123 *124 * @return string A template path125 */126 static public function getTemplatePath($moduleName, $templateFile)127 {128 $dir = self::getTemplateDir($moduleName, $templateFile);129 130 return $dir ? $dir.'/'.$templateFile : null;131 }132 133 /**134 * Gets the i18n directories to use globally.135 *136 * @return array An array of i18n directories137 */138 static public function getI18NGlobalDirs()139 {140 $dirs = array();141 142 // application143 if (is_dir($dir = sfConfig::get('sf_app_dir').'/'.sfConfig::get('sf_app_module_i18n_dir_name')))144 {145 $dirs[] = $dir;146 }147 148 // plugins149 $pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.sfConfig::get('sf_app_module_i18n_dir_name'));150 if (isset($pluginDirs[0]))151 {152 $dirs[] = $pluginDirs[0];153 }154 155 return $dirs;156 }157 158 /**159 * Gets the i18n directories to use for a given module.160 *161 * @param string The module name162 *163 * @return array An array of i18n directories164 */165 static public function getI18NDirs($moduleName)166 {167 $dirs = array();168 169 // module170 if (is_dir($dir = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_i18n_dir_name')))171 {172 $dirs[] = $dir;173 }174 175 // application176 if (is_dir($dir = sfConfig::get('sf_app_dir').'/'.sfConfig::get('sf_app_module_i18n_dir_name')))177 {178 $dirs[] = $dir;179 }180 181 // module in plugins182 $pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/modules/'.$moduleName.'/'.sfConfig::get('sf_app_module_i18n_dir_name'));183 if (isset($pluginDirs[0]))184 {185 $dirs[] = $pluginDirs[0];186 }187 188 // plugins189 $pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.sfConfig::get('sf_app_module_i18n_dir_name'));190 if (isset($pluginDirs[0]))191 {192 $dirs[] = $pluginDirs[0];193 }194 195 return $dirs;196 }197 198 /**199 * Gets directories where template files are stored for a generator class and a specific theme.200 *201 * @param string The generator class name202 * @param string The theme name203 *204 * @return array An array of directories205 */206 static public function getGeneratorTemplateDirs($class, $theme)207 {208 $dirs = array(sfConfig::get('sf_data_dir').'/generator/'.$class.'/'.$theme.'/template'); // project209 210 if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/data/generator/'.$class.'/'.$theme.'/template'))211 {212 $dirs = array_merge($dirs, $pluginDirs); // plugin213 }214 215 if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/data/generator/'.$class.'/'.$theme.'/template'))216 {217 $dirs = array_merge($dirs, $bundledPluginDirs); // bundled plugin218 }219 220 return $dirs;221 }222 223 /**224 * Gets directories where the skeleton is stored for a generator class and a specific theme.225 *226 * @param string The generator class name227 * @param string The theme name228 *229 * @return array An array of directories230 */231 static public function getGeneratorSkeletonDirs($class, $theme)232 {233 $dirs = array(sfConfig::get('sf_data_dir').'/generator/'.$class.'/'.$theme.'/skeleton'); // project234 235 if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/data/generator/'.$class.'/'.$theme.'/skeleton'))236 {237 $dirs = array_merge($dirs, $pluginDirs); // plugin238 }239 240 if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/data/generator/'.$class.'/'.$theme.'/skeleton'))241 {242 $dirs = array_merge($dirs, $bundledPluginDirs); // bundled plugin243 }244 245 return $dirs;246 }247 248 /**249 * Gets the template to use for a generator class.250 *251 * @param string The generator class name252 * @param string The theme name253 * @param string The template path254 *255 * @return string A template path256 *257 * @throws sfException258 */259 static public function getGeneratorTemplate($class, $theme, $path)260 {261 $dirs = self::getGeneratorTemplateDirs($class, $theme);262 foreach ($dirs as $dir)263 {264 if (is_readable($dir.'/'.$path))265 {266 return $dir.'/'.$path;267 }268 }269 270 throw new sfException(sprintf('Unable to load "%s" generator template in: %s.', $path, implode(', ', $dirs)));271 }272 273 /**274 * Gets the configuration file paths for a given relative configuration path.275 *276 * @param string The configuration path277 *278 * @return array An array of paths279 */280 static public function getConfigPaths($configPath)281 {282 $globalConfigPath = basename(dirname($configPath)).'/'.basename($configPath);283 284 $files = array(285 sfConfig::get('sf_symfony_lib_dir').'/config/'.$globalConfigPath, // symfony286 );287 288 if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/'.$globalConfigPath))289 {290 $files = array_merge($files, $bundledPluginDirs); // bundled plugins291 }292 293 if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.$globalConfigPath))294 {295 $files = array_merge($files, $pluginDirs); // plugins296 }297 298 $files = array_merge($files, array(299 sfConfig::get('sf_root_dir').'/'.$globalConfigPath, // project300 sfConfig::get('sf_root_dir').'/'.$configPath, // project301 sfConfig::get('sf_app_dir').'/'.$globalConfigPath, // application302 sfConfig::get('sf_app_cache_dir').'/'.$configPath, // generated modules303 ));304 305 if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.$configPath))306 {307 $files = array_merge($files, $pluginDirs); // plugins308 }309 310 $files[] = sfConfig::get('sf_app_dir').'/'.$configPath; // module311 312 $configs = array();313 foreach (array_unique($files) as $file)314 {315 if (is_readable($file))316 {317 $configs[] = $file;318 }319 }320 321 return $configs;322 }323 324 21 /** 325 22 * Gets the helper directories for a given module name. … … 412 109 } 413 110 } 414 415 /**416 * Loads config.php files from plugins417 *418 * @return void419 */420 static public function loadPluginConfig()421 {422 if ($pluginConfigs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/config/config.php'))423 {424 foreach($pluginConfigs as $config)425 {426 require_once($config);427 }428 }429 430 if ($pluginConfigs = glob(sfConfig::get('sf_plugins_dir').'/*/config/config.php'))431 {432 foreach ($pluginConfigs as $config)433 {434 require_once($config);435 }436 }437 }438 111 } branches/1.1/lib/controller/default/templates/moduleSuccess.php
r7329 r7614 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/1.1/lib/controller/sfController.class.php
r7215 r7614 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( 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/1.1/lib/database/sfDatabaseManager.class.php
r7442 r7614 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/1.1/lib/filter/sfFilterChain.class.php
r6499 r7614 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/1.1/lib/generator/sfCrudGenerator.class.php
r7480 r7614 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/1.1/lib/generator/sfGenerator.class.php
r6156 r7614 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/1.1/lib/generator/sfGeneratorManager.class.php
r4957 r7614 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/1.1/lib/i18n/extract/sfI18nModuleExtract.class.php
r4359 r7614 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/1.1/lib/i18n/sfI18N.class.php
r6721 r7614 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, sfCache $cache = null, $options = array())35 { 36 $this->initialize($ dispatcher, $cache, $options);35 public function __construct(sfApplicationConfiguration $configuration, sfCache $cache = null, $options = array()) 36 { 37 $this->initialize($configuration, $cache, $options); 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, sfCache $cache = null, $options = array()) 47 { 48 $this->dispatcher = $dispatcher; 49 $this->cache = $cache; 43 * @param sfApplicationConfiguration A sfApplicationConfiguration instance 44 * @param sfCache A sfCache instance 45 * @param array An array of options 46 */ 47 public function initialize(sfApplicationConfiguration $configuration, sfCache $cache = null, $options = array()) 48 { 49 $this->configuration = $configuration; 50 $this->dispatcher = $configuration->getEventDispatcher(); 51 $this->cache = $cache; 50 52 51 53 if (isset($options['culture'])) … … 63 65 ), $options); 64 66 65 $dispatcher->connect('user.change_culture', array($this, 'listenToChangeCultureEvent')); 66 $dispatcher->connect('controller.change_action', array($this, 'listenToChangeActionEvent')); 67 $this->dispatcher->connect('user.change_culture', array($this, 'listenToChangeCultureEvent')); 68 $this->dispatcher->connect('controller.change_action', array($this, 'listenToChangeActionEvent')); 69 } 70 71 /** 72 * Returns the configuration instance. 73 * 74 * @return sfApplicationConfiguration An sfApplicationConfiguration instance 75 */ 76 public function getConfiguration() 77 { 78 return $this->configuration; 67 79 } 68 80 … … 148 160 if (!isset($this->messageSource)) 149 161 { 150 $this->setMessageSource( sfLoader::getI18NGlobalDirs(), $this->culture);162 $this->setMessageSource($this->configuration->getI18NGlobalDirs(), $this->culture); 151 163 } 152 164 … … 314 326 { 315 327 // change message source directory to our module 316 $this->setMessageSource( sfLoader::getI18NDirs($event['module']));328 $this->setMessageSource($this->configuration->getI18NDirs($event['module'])); 317 329 } 318 330 } branches/1.1/lib/plugins/sfCompat10Plugin/config/config.php
r6713 r7614 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/1.1/lib/plugins/sfCompat10Plugin/lib/filter/sfValidationExecutionFilter.class.php
r5814 r7614 113 113 // load validation configuration 114 114 // do NOT use require_once 115 if (null !== $validateFile = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfig, true))115 if (null !== $validateFile = $this->context->getConfigCache()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfig, true)) 116 116 { 117 117 // create validator manager branches/1.1/lib/plugins/sfCompat10Plugin/lib/helper/PartialHelper.php
r6624 r7614 133 133 134 134 // load component's module config file 135 require(sfCon figCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml'));135 require(sfContext::getInstance()->getConfigCache()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml')); 136 136 137 137 $componentInstance->getVarHolder()->add($vars); branches/1.1/lib/plugins/sfCompat10Plugin/lib/view/sfMailView.class.php
r5106 r7614 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/1.1/lib/plugins/sfCompat10Plugin/test/bootstrap/functional.php
r5384 r7614 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/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/symfony
r7433 r7614 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/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/functional.php
r5320 r7614 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/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/test/bootstrap/unit.php
r5320 r7614 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/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/frontend_dev.php
r5320 r7614 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/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/web/index.php
r5320 r7614 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/1.1/lib/plugins/sfPropelPlugin/config/config.php
r5100 r7614 1 1 <?php 2 2 3 set_include_path( get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/../lib/vendor');3 set_include_path(sfConfig::get('sf_root_dir').PATH_SEPARATOR.get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/../lib/vendor'); branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelCrudGenerator.class.php
r4951 r7614 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/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php
r7153 r7614 429 429 protected function loadBuilders() 430 430 { 431 $classes = sfFinder::type('file')->name('*MapBuilder.php')->in( sfLoader::getModelDirs());431 $classes = sfFinder::type('file')->name('*MapBuilder.php')->in($this->generatorManager->getConfiguration()->getModelDirs()); 432 432 foreach ($classes as $class) 433 433 { branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelAutoload.php
r6970 r7614 17 17 require_once 'propel/Propel.php'; 18 18 19 $dispatcher = sf Context::getInstance()->getEventDispatcher();19 $dispatcher = sfProjectConfiguration::getActive()->getEventDispatcher(); 20 20 21 21 if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelData.class.php
r7399 r7614 271 271 protected function loadMapBuilders() 272 272 { 273 $files = sfFinder::type('file')->name('*MapBuilder.php')->in(sf Loader::getModelDirs());273 $files = sfFinder::type('file')->name('*MapBuilder.php')->in(sfProjectConfiguration::getActive()->getModelDirs()); 274 274 foreach ($files as $file) 275 275 { branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelManyToMany.class.php
r6970 r7614 52 52 53 53 // we must load all map builder classes 54 $classes = sfFinder::type('file')->name('*MapBuilder.php')->in(sf Loader::getModelDirs());54 $classes = sfFinder::type('file')->name('*MapBuilder.php')->in(sfProjectConfiguration::getActive()->getModelDirs()); 55 55 foreach ($classes as $class) 56 56 { branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBaseTask.class.php
r7476 r7614 33 33 if (!self::$done) 34 34 { 35 set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/../vendor'); 36 35 37 $libDir = dirname(__FILE__).'/..'; 36 38 branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildFormsTask.class.php
r7398 r7614 61 61 $this->logSection('propel', 'generating form classes'); 62 62 63 $generatorManager = new sfGeneratorManager( );63 $generatorManager = new sfGeneratorManager($this->configuration); 64 64 65 65 $generatorManager->generate('sfPropelFormGenerator', array('connection' => $options['connection'])); branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataDumpTask.class.php
r7447 r7614 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/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataLoadTask.class.php
r7447 r7614 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/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelGenerateCrudTask.class.php
r7435 r7614 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'], … … 136 136 // create basic application structure 137 137 $finder = sfFinder::type('any')->ignore_version_control()->discard('.sf'); 138 $dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelCrud', $options['theme']);138 $dirs = $this->configuration->getGeneratorSkeletonDirs('sfPropelCrud', $options['theme']); 139 139 foreach ($dirs as $dir) 140 140 { branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInitAdminTask.class.php
r7401 r7614 78 78 // create module structure 79 79 $finder = sfFinder::type('any')->ignore_version_control()->discard('.sf'); 80 $dirs = sfLoader::getGeneratorSkeletonDirs('sfPropelAdmin', $options['theme']);80 $dirs = $this->configuration->getGeneratorSkeletonDirs('sfPropelAdmin', $options['theme']); 81 81 foreach ($dirs as $dir) 82 82 { branches/1.1/lib/plugins/sfPropelPlugin/test/bootstrap/functional.php
r7183 r7614 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 … … 62 60 { 63 61 // initialize database manager 64 $databaseManager = new sfDatabaseManager( );62 $databaseManager = new sfDatabaseManager($configuration); 65 63 66 64 // cleanup database branches/1.1/lib/plugins/sfPropelPlugin/test/functional/backendTestBrowser.class.php
r6482 r7614 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/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/symfony
r7433 r7614 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/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/functional.php
r5260 r7614 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/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/test/bootstrap/unit.php
r5103 r7614 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/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/backend_dev.php
r5103 r7614 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/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud.php
r5103 r7614 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/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/crud_dev.php
r5103 r7614 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/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/web/index.php
r5103 r7614 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/1.1/lib/routing/sfPatternRouting.class.php
r7611 r7614 71 71 public function loadConfiguration() 72 72 { 73 if ($config = sfCon figCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/routing.yml', true))73 if ($config = sfContext::getInstance()->getConfigCache()->checkConfig('config/routing.yml', true)) 74 74 { 75 75 include($config); branches/1.1/lib/task/generator/sfGenerateAppTask.class.php
r7463 r7614 113 113 )); 114 114 115 $this->getFilesystem()->copy(dirname(__FILE__).'/skeleton/app/lib/ApplicationConfiguration.class.php', sfConfig::get('sf_lib_dir').'/'.$app.'Configuration.class.php'); 116 117 $this->getFilesystem()->replaceTokens(sfConfig::get('sf_lib_dir').'/'.$app.'Configuration.class.php', '##', '##', array('APP_NAME' => $app)); 118 115 119 $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); 116 120 $fixPerms->setCommandApplication($this->commandApplication); branches/1.1/lib/task/generator/sfGenerateProjectTask.class.php
r7401 r7614 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__).'/skeleton/project', sfConfig::get('sf_root_dir'), $finder); 72 72 73 // Update project name and directory73 // update project name and directory 74 74 $finder = sfFinder::type('file')->name('properties.ini', 'apache.conf', 'propel.ini'); 75 $this->getFilesystem()->replaceTokens($finder->in(sfConfig::get('sf_config_dir')), '##', '##', array('PROJECT_NAME' => $arguments['name'], 76 'PROJECT_DIR' => sfConfig::get('sf_root_dir'))); 75 $this->getFileSystem()->replaceTokens($finder->in(sfConfig::get('sf_config_dir')), '##', '##', array('PROJECT_NAME' => $arguments['name'], 'PROJECT_DIR' => sfConfig::get('sf_root_dir'))); 77 76 78 // Update config/config.php 79 $this->getFilesystem()->replaceTokens(sfConfig::get('sf_config_dir').'/config.php', '##', '##', array( 80 'SYMFONY_LIB_DIR' => sfConfig::get('sf_symfony_lib_dir'), 81 )); 77 // update ProjectConfiguration class 78 $this->getFileSystem()->replaceTokens(sfConfig::get('sf_lib_dir').'/ProjectConfiguration.class.php', '##', '##', array('SYMFONY_LIB_DIR' => sfConfig::get('sf_symfony_lib_dir'))); 82 79 83 80 $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); branches/1.1/lib/task/generator/skeleton/app/web/index.php
r7463 r7614 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/1.1/lib/task/generator/skeleton/project/symfony
r7322 r7614 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/1.1/lib/task/generator/skeleton/project/test/bootstrap/functional.php
r6222 r7614 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/1.1/lib/task/generator/skeleton/project/test/bootstrap/unit.php
r2369 r7614 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/1.1/lib/task/i18n/sfI18nExtractTask.class.php
r7430 r7614 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 $extract->extract(); 90 88 branches/1.1/lib/task/i18n/sfI18nFindTask.class.php
r7397 r7614 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/1.1/lib/task/project/sfProjectClearControllersTask.class.php
r7401 r7614 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/1.1/lib/task/project/sfProjectFreezeTask.class.php
r7401 r7614 70 70 } 71 71 72 $symfony _lib_dir = sfConfig::get('sf_symfony_lib_dir');73 $symfony _data_dir = $arguments['symfony_data_dir'];72 $symfonyLibDir = sfConfig::get('sf_symfony_lib_dir'); 73 $symfonyDataDir = $arguments['symfony_data_dir']; 74 74 75 $this->logSection('freeze', sprintf('freezing lib found in "%s', $symfony _lib_dir));76 $this->logSection('freeze', sprintf('freezing data found in "%s"', $symfony _data_dir));75 $this->logSection('freeze', sprintf('freezing lib found in "%s', $symfonyLibDir)); 76 $this->logSection('freeze', sprintf('freezing data found in "%s"', $symfonyDataDir)); 77 77 78 78 $this->getFilesystem()->mkdirs('lib'.DIRECTORY_SEPARATOR.'symfony'); 79 79 $this->getFilesystem()->mkdirs('data'.DIRECTORY_SEPARATOR.'symfony'); 80 80 81 $finder = sfFinder::type('any')->ignore_version_control(); 82 $this->getFilesystem()->mirror($symfony_lib_dir, sfConfig::get('sf_lib_dir').'/symfony', $finder); 83 $this->getFilesystem()->mirror($symfony_data_dir, sfConfig::get('sf_data_dir').'/symfony', $finder); 84 81 $finder = sfFinder::type('any')->ignore_version_control()->exec(array($this, 'excludeTests')); 82 $this->getFilesystem()->mirror($symfonyLibDir, sfConfig::get('sf_lib_dir').'/symfony', $finder); 83 $this->getFilesystem()->mirror($symfonyDataDir, sfConfig::get('sf_data_dir').'/symfony', $finder); 85 84 $this->getFilesystem()->rename(sfConfig::get('sf_data_dir').'/symfony/web/sf', sfConfig::get('sf_web_dir').'/sf'); 86 85 87 // change symfony paths in config/config.php 88 file_put_contents('config/config.php.bak', $symfony_lib_dir); 89 $this->changeSymfonyDirs("dirname(__FILE__).'/../lib/symfony'"); 86 // change symfony path in ProjectConfiguration.class.php 87 $config = sfConfig::get('sf_lib_dir').'/ProjectConfiguration.class.php'; 88 $content = file_get_contents($config); 89 $content = str_replace('<?php', "<?php\n\n# FROZEN_SF_LIB_DIR: $symfonyLibDir", $content); 90 $content = preg_replace('#(\'|")'.preg_quote($symfonyLibDir, '#').'#', "dirname(__FILE__).$1/../lib/symfony", $content); 91 file_put_contents($config, $content); 90 92 } 91 93 92 p rotected function changeSymfonyDirs($symfony_lib_dir)94 public function excludeTests($dir, $entry) 93 95 { 94 $content = file_get_contents('config/config.php'); 95 $content = preg_replace("/^(\s*.sf_symfony_lib_dir\s*=\s*).+?;/m", "$1$symfony_lib_dir;", $content); 96 file_put_contents('config/config.php', $content); 96 return false === strpos($dir.'/'.$entry, 'Plugin/test/'); 97 97 } 98 98 } branches/1.1/lib/task/project/sfProjectUnfreezeTask.class.php
r7401 r7614 51 51 } 52 52 53 $this->changeSymfonyDirs("'".file_get_contents('config/config.php.bak')."'"); 53 // change symfony path in ProjectConfiguration.class.php 54 $config = sfConfig::get('sf_lib_dir').'/ProjectConfiguration.class.php'; 55 $content = file_get_contents($config); 56 if (preg_match('/^# FROZEN_SF_LIB_DIR\: (.+?)$/m', $content, $match)) 57 { 58 $content = str_replace("# FROZEN_SF_LIB_DIR: {$match[1]}\n\n", '', $content); 59 $content = preg_replace('#^require_once.+?$#m', "require_once '{$match[1]}/autoload/sfCoreAutoload.class.php';", $content, 1); 60 file_put_contents($config, $content); 61 } 54 62 55 63 $finder = sfFinder::type('any'); … … 60 68 $this->getFilesystem()->remove($finder->in(sfConfig::get('sf_web_dir').'/sf')); 61 69 $this->getFilesystem()->remove(sfConfig::get('sf_web_dir').'/sf'); 62 }63 64 protected function changeSymfonyDirs($symfony_lib_dir)65 {66 $content = file_get_contents('config/config.php');67 $content = preg_replace("/^(\s*.sf_symfony_lib_dir\s*=\s*).+?;/m", "$1$symfony_lib_dir;", $content);68 file_put_contents('config/config.php', $content);69 70 } 70 71 } branches/1.1/lib/task/project/upgrade1.1/sfConfigUpgrade.class.php
r7397 r7614 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/1.1/lib/task/project/upgrade1.1/sfUpgrade.class.php
r7409 r7614 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/1.1/lib/task/sfBaseTask.class.php
r7401 r7614 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 = 'dev', $debug = true)74 {75 if (defined('SF_ROOT_DIR'))76 {77 return;78 }79 80 define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));81 define('SF_APP', $app);82 define('SF_ENVIRONMENT', $env);83 define('SF_DEBUG', $debug);84 85 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');86 87 sfContext::getInstance();88 67 } 89 68 branches/1.1/lib/util/sfBrowser.class.php
r6867 r7614 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 … … 235 235 236 236 // dispatch our request 237 ob_start();238 237 $controller->dispatch(); 238 239 239 $retval = ob_get_clean(); 240 240 … … 369 369 370 370 /** 371 * Gets context. 371 * Returns the current application context. 372 * 373 * @param Boolean true to force context reload, false otherwise 372 374 * 373 375 * @return sfContext 374 376 */ 375 public function getContext() 376 { 377 public function getContext($forceReload = false) 378 { 379 if (is_null($this->context) || $forceReload) 380 { 381 $this->context = sfContext::getInstance(); 382 $this->context->initialize($this->context->getConfiguration()); 383 $this->context->getEventDispatcher()->connect('application.throw_exception', array($this, 'ListenToException')); 384 } 385 377 386 return $this->context; 378 387 } branches/1.1/lib/util/sfContext.class.php
r7140 r7614 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->printStackTrace(); 57 } 58 catch (Exception $e) 59 { 60 sfException::createFromException($e)->printStackTrace(); 61 } 62 63 if (sfConfig::get('sf_logging_enabled')) 64 { 65 $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Initialization'))); 66 } 67 68 $this->dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters')); 69 70 // register our shutdown function 71 register_shutdown_function(array($this, 'shutdown')); 72 } 73 74 /** 75 * Retrieves the singleton instance of this class. 76 * 77 * @param string The name of the sfContext to retrieve. 78 * 79 * @return sfContext A sfContext implementation instance. 80 */ 81 public static function getInstance($name = null, $class = __CLASS__) 35 * Creates a new context instance. 36 * 37 * @param sfApplicationConfiguration A sfApplicationConfiguration instance 38 * @param string A name for this context (application name by default) 39 * @param string The context class to use (sfContext by default) 40 * 41 * @return sfContext A sfContext instance 42 */ 43 static public function createInstance(sfApplicationConfiguration $configuration, $name = null, $class = __CLASS__) 82 44 { 83 45 if (is_null($name)) 84 46 { 85 $name = self::$current; 86 } 47 $name = $configuration->getApplication(); 48 } 49 50 self::$current = $name; 87 51 88 52 if (!isset(self::$instances[$name])) … … 95 59 } 96 60 97 self::$instances[$name]->initialize( );61 self::$instances[$name]->initialize($configuration); 98 62 } 99 63 … … 102 66 103 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->printStackTrace(); 84 } 85 catch (Exception $e) 86 { 87 sfException::createFromException($e)->printStackTrace(); 88 } 89 90 if (sfConfig::get('sf_logging_enabled')) 91 { 92 $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Initialization'))); 93 } 94 95 $this->dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters')); 96 97 // register our shutdown function 98 register_shutdown_function(array($this, 'shutdown')); 99 } 100 101 /** 102 * Retrieves the singleton instance of this class. 103 * 104 * @param string The name of the sfContext to retrieve. 105 * 106 * @return sfContext A sfContext implementation instance. 107 */ 108 static public function getInstance($name = null, $class = __CLASS__) 109 { 110 if (is_null($name)) 111 { 112 $name = self::$current; 113 } 114 115 if (!isset(self::$instances[$name])) 116 { 117 throw new sfException(sprintf('The "%s" context does not exist.', $name)); 118 } 119 120 return self::$instances[$name]; 121 } 122 123 /** 104 124 * Checks to see if there has been a context created 105 125 * 106 * @param string The name of the sfContext to check for126 * @param string The name of the sfContext to check for 107 127 * 108 128 * @return boolean True is instanced, otherwise false … … 120 140 121 141 /** 122 * 142 * Loads the symfony factories. 143 */ 144 public function loadFactories() 145 { 146 if (sfConfig::get('sf_use_database')) 147 { 148 // setup our database connections 149 $this->factories['databaseManager'] = new sfDatabaseManager($this->configuration, array('auto_shutdown' => false)); 150 } 151 152 // create a new action stack 153 $this->factories['actionStack'] = new sfActionStack(); 154 155 // include the factories configuration 156 require($this->configuration->getConfigCache()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/factories.yml')); 157 158 $this->dispatcher->notify(new sfEvent($this, 'context.load_factories')); 159 } 160 161 /** 162 * Dispatches the current request. 163 */ 164 public function dispatch() 165 { 166 $this->getController()->dispatch(); 167 } 168 169 /** 123 170 * Sets the current context to something else 124 171 * … … 129 176 { 130 177 self::$current = $name; 178 } 179 180 /** 181 * Returns the configuration instance. 182 * 183 * @return sfConfiguration The sfConfiguration instance 184 */ 185 public function getConfiguration() 186 { 187 return $this->configuration; 131 188 } 132 189 … … 346 403 347 404 /** 405 * Returns the configuration cache. 406 * 407 * @return sfConfigCache A sfConfigCache instance 408 */ 409 public function getConfigCache() 410 { 411 return $this->configuration->getConfigCache(); 412 } 413 414 /** 348 415 * Gets an object from the current context. 349 416 * branches/1.1/lib/view/sfPHPView.class.php
r7407 r7614 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/1.1/lib/view/sfPartialView.class.php
r7407 r7614 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/1.1/lib/view/sfViewCacheManager.class.php
r6509 r7614 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/1.1/test/bin/loc.php
r7370 r7614 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/1.1/test/bootstrap/functional.php
r6870 r7614 21 21 $root_dir = realpath(dirname(__FILE__).sprintf('/../%s/fixtures/project', isset($type) ? $type : 'functional')); 22 22 } 23 define('SF_ROOT_DIR', $root_dir);24 define('SF_APP', $app);25 define('SF_ENVIRONMENT', 'test');26 define('SF_DEBUG', isset($debug) ? $debug : true);27 23 28 // initialize symfony 29 require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 24 $class = $app.'Configuration'; 25 require $root_dir.'/lib/'.$class.'.class.php'; 26 $configuration = new $class('test', isset($debug) ? $debug : true); 27 sfContext::createInstance($configuration); 30 28 31 29 // remove all cache branches/1.1/test/functional/fixtures/project/symfony
r7433 r7614 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/1.1/test/functional/fixtures/project/test/bootstrap/functional.php
r5260 r7614 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/1.1/test/functional/fixtures/project/test/bootstrap/unit.php
r2543 r7614 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/1.1/test/functional/fixtures/project/web/cache.php
r2369 r7614 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/1.1/test/functional/fixtures/project/web/cache_dev.php
r2369 r7614 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/1.1/test/functional/fixtures/project/web/frontend_dev.php
r2369 r7614 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/1.1/test/functional/fixtures/project/web/i18n.php
r2740 r7614 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/1.1/test/functional/fixtures/project/web/i18n_dev.php
r2740 r7614 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/1.1/test/functional/fixtures/project/web/index.php
r2369 r7614 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/1.1/test/other/tasksTest.php
r7332 r7614 121 121 122 122 $content = $c->execute_command(sprintf('project:freeze %s', realpath(dirname(__FILE__).'/../../data'))); 123 $t->like(file_get_contents($c->tmp_dir.DS.' config'.DS.'config.php'), '/dirname\(__FILE__\)/', '"project:freeze" freezes symfony lib and data dir into the project directory');123 $t->like(file_get_contents($c->tmp_dir.DS.'lib'.DS.'ProjectConfiguration.class.php'), '/dirname\(__FILE__\)/', '"project:freeze" freezes symfony lib and data dir into the project directory'); 124 124 125 125 $content = $c->execute_command('project:unfreeze'); 126 $t->unlike(file_get_contents($c->tmp_dir.DS.' config'.DS.'config.php'), '/dirname\(__FILE__\)/', '"project:unfreeze" unfreezes symfony lib and data dir');126 $t->unlike(file_get_contents($c->tmp_dir.DS.'lib'.DS.'ProjectConfiguration.class.php'), '/dirname\(__FILE__\)/', '"project:unfreeze" unfreezes symfony lib and data dir'); 127 127 128 128 $c->shutdown(); branches/1.1/test/unit/config/sfConfigCacheTest.php
r3703 r7614 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/1.1/test/unit/generator/sfGeneratorTest.php
r4957 r7614 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/1.1/test/unit/i18n/extract/sfI18nExtractTest.php
r7430 r7614 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, $cache);29 $i18n = new sfI18N($configuration, $cache); 26 30 27 31 class sfI18nExtractTest extends sfI18nExtract branches/1.1/test/unit/i18n/sfI18NTest.php
r6684 r7614 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, $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, $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, $cache, array('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, $cache, array('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, $cache, array('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, $cache, array('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, $cache, array('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, $cache, array('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, $cache, array('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/1.1/test/unit/task/cache/sfCacheClearTaskTest.php
r6859 r7614 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/1.1/test/unit/util/sfContextTest.php
r4449 r7614 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 */

